[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] Building a single cross-compiler: please test new con
From: |
Michael Matz |
Subject: |
Re: [Tinycc-devel] Building a single cross-compiler: please test new configure |
Date: |
Thu, 10 Apr 2014 18:01:10 +0200 (CEST) |
User-agent: |
Alpine 2.00 (LNX 1167 2008-08-23) |
Hello Thomas,
On Wed, 9 Apr 2014, Thomas Preud'homme wrote:
> I have a patch to build a single cross-compiler by using --targetcpu but
> given the potential of breakage of the build script I prefer to post it
> here for now and ask you to try building tcc with it, either natively or
> all the cross compilers to see if anything break.
>
> You can also try building a single compiler to see if it works for you
> or take a look at the patch. Any feedback welcome.
No cake yet, there are multiple problems. Some of them are fixed by the
attached second version of that patch (which applies on top of current
mob). The changes are:
* inconsistent use of X64, x86_64 and x86-64. This now matters because
sometimes directory names implies make targets and variables now. I've
settled on x86_64, because from that we can infer also C macros
* configure would unconditionally put #define TCC_TARGET_$ARCH in
config.h. When building cross compilers that would define the native
arch and the cross arch for the same executable. So go back to adding
the right define in the Makefile
* The correct spelling of the make function is 'filter-out' (not with
underscore)
* libtcc1.c needs access to size_t also for cross environment
(no idea why it would be there before the patch), so include <stddef.h>
With that patch the following works on an x86_64 host:
% ./configure && make && make test
and
% linux32 ./configure CC="gcc -m32" \
&& sed -i -e 's/lib64/lib/' config.mak \
&& linux32 make CFLAGS=-g CC="gcc -m32" \
&& linux32 make CFLAGS=-g CC="gcc -m32" -k test
I.e. the two native compilers for such host. Some host compilers compile
as well:
% ./configure --targetcpu=i386 && make
The resulting i386-tcc cannot build binaries (with "./i386-tcc -B./"
because libtcc1.a isn't found (seems it's not searched in ./lib/i386).
This works before the patch. Similar this other cross compiler:
% linux32 ./configure CC="gcc -m32" --targetcpu=x86_64 && make
Produces a 32bit x86_64-tcc executable (correct), which can't link
executables, because it searches in /usr/lib for crt[1in].o and doesn't
find libgcc1.a
Also:
% ./configure --enable-cross && make
...
make -C lib cross TARGET=i386-win32 PROG_CROSS=
make[1]: Entering directory `/matz/git/tinycc/lib'
../ -B../win32 -I../include -c libtcc1.c -o i386-win32/libtcc1.o -I.. -g
-DTCC_TARGET_I386 -DTCC_TARGET_PE
make[1]: execvp: ../: Permission denied
make[1]: *** [i386-win32/libtcc1.o] Error 127
make[1]: Leaving directory `/matz/git/tinycc/lib'
make: *** [lib/i386-win32/libtcc1.a] Error 2
This points to a general problem in how the Makefile infers some names for
the compiler to build the target lib. You have:
lib/%/libtcc1.a : FORCE $(filter $*%,$(PROGS_CROSS))
$(MAKE) -C lib cross TARGET=$* PROG_CROSS=$(filter $*%,$(PROGS_CROSS))
The '%' is i386, i386-win32, x86_64-win32, x86_64 and arm. But in
$(PROGS_CROSS) there is only "i386-w64-mingw32-tcc" which doesn't match
"i386-win32". With arm it's even worse, because there we have four cross
compilers in PROGS_CROSS, that all match "arm%".
So, that needs some more work still. I've attached the patch I have up to
now (need to leave now). The result of interdiff of both patches (yours
vs. mine) is below to easier see what exactly I've changed relative to
yours.
Thanks for starting to clean up the cross stuff.
Ciao,
Michael.
-----------------------------
diff -u b/Makefile b/Makefile
--- b/Makefile
+++ b/Makefile
@@ -67,6 +67,7 @@
NATIVE_DEFINES_$(CONFIG_arm_eabi) += -DTCC_ARM_EABI
NATIVE_DEFINES_$(CONFIG_arm_vfp) += -DTCC_ARM_VFP
NATIVE_DEFINES += $(NATIVE_DEFINES_yes)
+NATIVE_DEFINES += -DTCC_TARGET_$(ARCH)
ifeq ($(TOP),.)
@@ -74,7 +75,7 @@
WIN32_CROSS = i386-w64-mingw32-tcc$(EXESUF)
WIN64_CROSS = x86_64-w64-mingw32-tcc$(EXESUF)
WINCE_CROSS = arm-wince-mingw32ce-tcc$(EXESUF)
-X64_CROSS = x86_64-linux-gnu-tcc$(EXESUF)
+X86_64_CROSS = x86_64-linux-gnu-tcc$(EXESUF)
ARM_FPA_CROSS = arm-linux-fpa-tcc$(EXESUF)
ARM_FPA_LD_CROSS = arm-linux-fpa-ld-tcc$(EXESUF)
ARM_VFP_CROSS = arm-linux-gnu-tcc$(EXESUF)
@@ -88,7 +89,7 @@
$(WIN32_CROSS)_LINK = i386-win32-tcc$(EXESUF)
$(WIN64_CROSS)_LINK = x86_64-win32-tcc$(EXESUF)
$(WINCE_CROSS)_LINK = arm-win32-tcc$(EXESUF)
-$(X64_CROSS)_LINK = x86_64-tcc$(EXESUF)
+$(X86_64_CROSS)_LINK = x86_64-tcc$(EXESUF)
$(ARM_FPA_CROSS)_LINK = arm-fpa-tcc$(EXESUF)
$(ARM_FPA_LD_CROSS)_LINK = arm-fpa-ld-tcc$(EXESUF)
$(ARM_VFP_CROSS)_LINK = arm-vfp-tcc$(EXESUF)
@@ -107,7 +108,7 @@
I386_LIBTCC1_CROSS=lib/i386/libtcc1.a
WIN32_LIBTCC1_CROSS=lib/i386-win32/libtcc1.a
WIN64_LIBTCC1_CROSS=lib/x86_64-win32/libtcc1.a
-X86_64_LIBTCC1_CROSS=lib/x86-64/libtcc1.a
+X86_64_LIBTCC1_CROSS=lib/x86_64/libtcc1.a
ARM_LIBTCC1_CROSS=lib/arm/libtcc1.a
ifdef CONFIG_WIN64
@@ -116,7 +117,7 @@
ARCH=WIN32
endif
-TARGET_ALL=WIN32 WIN64 I386 X64 ARM C67
+TARGET_ALL=WIN32 WIN64 I386 X86_64 ARM C67
ifdef TARGET_ARCH
NATIVE_FILES=
PROGS_CROSS=$($(TARGET_ARCH)_CROSS)
@@ -125,8 +126,8 @@
else
PROGS=tcc$(EXESUF)
NATIVE_FILES=$($(ARCH)_FILES)
-PROGS_CROSS=$(foreach CROSS_ARCH,$(filter_out
$(ARCH),$(TARGET_ALL)),$($(CROSS_ARCH)_CROSS))
-LIBTCC1_CROSS=$(foreach CROSS_ARCH,$(filter_out
$(ARCH),$(TARGET_ALL)),$($(CROSS_ARCH)_LIBTCC1_CROSS))
+PROGS_CROSS=$(foreach CROSS_ARCH,$(filter-out
$(ARCH),$(TARGET_ALL)),$($(CROSS_ARCH)_CROSS))
+LIBTCC1_CROSS=$(foreach CROSS_ARCH,$(filter-out
$(ARCH),$(TARGET_ALL)),$($(CROSS_ARCH)_LIBTCC1_CROSS))
LIBTCC1=libtcc1.a
endif
PROGS_CROSS_LINK=$(foreach PROG_CROSS,$(PROGS_CROSS),$($(PROG_CROSS)_LINK))
@@ -160,8 +161,8 @@
$(I386_CROSS): DEFINES = -DTCC_TARGET_I386 \
-DCONFIG_TCCDIR="\"$(tccdir)/i386\""
-$(X64_CROSS): DEFINES = -DTCC_TARGET_X86_64 \
- -DCONFIG_TCCDIR="\"$(tccdir)/x86-64\""
+$(X86_64_CROSS): DEFINES = -DTCC_TARGET_X86_64 \
+ -DCONFIG_TCCDIR="\"$(tccdir)/x86_64\""
$(WIN32_CROSS): DEFINES = -DTCC_TARGET_I386 -DTCC_TARGET_PE \
-DCONFIG_TCCDIR="\"$(tccdir)/win32\"" \
-DCONFIG_TCC_LIBPATHS="\"{B}/lib/32;{B}/lib\""
@@ -178,7 +179,7 @@
$(ARM_EABI_CROSS): DEFINES = -DTCC_TARGET_ARM -DTCC_ARM_EABI -DTCC_ARM_VFP
$(I386_CROSS): $(I386_FILES)
-$(X64_CROSS): $(X86_64_FILES)
+$(X86_64_CROSS): $(X86_64_FILES)
$(WIN32_CROSS): $(WIN32_FILES)
$(WIN64_CROSS): $(WIN64_FILES)
$(WINCE_CROSS): $(WINCE_FILES)
diff -u b/configure b/configure
--- b/configure
+++ b/configure
@@ -80,7 +80,7 @@
cpu="i386"
;;
x86_64|amd64)
- cpu="x86-64"
+ cpu="x86_64"
;;
arm*)
case "$cpu" in
@@ -445,7 +445,6 @@
if test "$build_cpu" != "$target_cpu" ; then
echo TARGET_ARCH="$TARGET_CPU" >> config.mak
fi
-echo "#define TCC_TARGET_$TARGET_CPU 1" >> $TMPH
if test "$target_cpu" = "arm" ; then
echo "#define TCC_ARM_VERSION $target_cpuver" >> $TMPH
fi
only in patch2:
unchanged:
--- a/lib/libtcc1.c
+++ b/lib/libtcc1.c
@@ -28,6 +28,7 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+#include <stddef.h>
#include <stdint.h>
#define W_TYPE_SIZE 32
crosstcc2.diff
Description: Text Data