History

Revert "tcc.h: Extend search path for include, lib and crt"

This reverts commit 2507c7170443cf4cced4d2cda8ba3c8cc259adb1. Why crowd up search-paths for the normal native compiler with all sort of invalid stuff. Why -UCONFIG_TRIPLET if it isn't set at all for cross-compilers. Also, the patch still didn't do anything useful "out of the box". Instead I'd suggest to do something more simple and more effective. See Makefile: - set search paths for cross-compilers to /usr/<triplet> by default - Install any built "xxx-tcc" and "xxx-libtcc1.a", even if not listed with PROGS_CROSS/LIBTCC1_CROSS - Support ELF-<target> = ... to set the elf interpreter Some common gnu-triplets are supported by default TRIPLET-i386 ?= i386-linux-gnu TRIPLET-x86_64 ?= x86_64-linux-gnu TRIPLET-arm ?= arm-linux-gnueabihf TRIPLET-arm64 ?= aarch64-linux-gnu TRIPLET-riscv64 ?= riscv64-linux-gnu Other triplets can be given explicitly, for example like this: $ make cross-arm-eabi TRIPLET-arm-eabi=arm-linux-gnueabi $ sudo make install

grischka committed 4 years ago

Commit e5eedc01 parent e41730f3 files · +19 −36Browse files

Unified · Split

3 files
  1. Makefile +18 −2
  2. config-extra.mak.example +0 −27
  3. tcc.h +1 −7
Makefile+18−2
@@ -171,6 +171,7 @@ DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"") · 170 unmodified lines
171171 DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"")
172172 DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"")
173173 DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")
174+DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"")
174175 DEFINES += $(DEF-$(or $(findstring win,$T),unx))
175176
176177 ifneq ($(X),)
@@ -186,6 +187,19 @@ endif · 9 unmodified lines
186187 # include custom configuration (see make help)
187188 -include config-extra.mak
188189
190+ifneq ($(X),)
191+# assume support files for cross-targets in "/usr/<triplet>" by default
192+TRIPLET-i386 ?= i386-linux-gnu
193+TRIPLET-x86_64 ?= x86_64-linux-gnu
194+TRIPLET-arm ?= arm-linux-gnueabihf
195+TRIPLET-arm64 ?= aarch64-linux-gnu
196+TRIPLET-riscv64 ?= riscv64-linux-gnu
197+TR = $(if $(TRIPLET-$T),$T,ignored)
198+CRT-$(TR) ?= /usr/$(TRIPLET-$T)/lib
199+LIB-$(TR) ?= {B}:/usr/$(TRIPLET-$T)/lib
200+INC-$(TR) ?= {B}/include:/usr/$(TRIPLET-$T)/include
201+endif
202+
189203 CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c
190204 CORE_FILES += tcc.h config.h libtcc.h tcctok.h
191205 i386_FILES = $(CORE_FILES) i386-gen.c i386-link.c i386-asm.c i386-asm.h i386-tok.h
@@ -339,7 +353,7 @@ INSTALLBIN = install -m755 $(STRIP_$(CONFIG_strip)) · 147 unmodified lines
339353 STRIP_yes = -s
340354
341355 LIBTCC1_W = $(filter %-win32-libtcc1.a %-wince-libtcc1.a,$(LIBTCC1_CROSS))
342−LIBTCC1_U = $(filter-out $(LIBTCC1_W),$(LIBTCC1_CROSS))
356+LIBTCC1_U = $(filter-out $(LIBTCC1_W),$(wildcard *-libtcc1.a))
343357 IB = $(if $1,$(IM) mkdir -p $2 && $(INSTALLBIN) $1 $2)
344358 IBw = $(call IB,$(wildcard $1),$2)
345359 IF = $(if $1,$(IM) mkdir -p $2 && $(INSTALL) $1 $2)
@@ -351,7 +365,7 @@ B_O = bcheck.o bt-exe.o bt-log.o bt-dll.o · 5 unmodified lines
351365
352366 # install progs & libs
353367 install-unx:
354− $(call IBw,$(PROGS) $(PROGS_CROSS),"$(bindir)")
368+ $(call IBw,$(PROGS) *-tcc,"$(bindir)")
355369 $(call IFw,$(LIBTCC1) $(B_O) $(LIBTCC1_U),"$(tccdir)")
356370 $(call IF,$(TOPSRC)/include/*.h $(TOPSRC)/tcclib.h,"$(tccdir)/include")
357371 $(call $(if $(findstring .so,$(LIBTCC)),IBw,IFw),$(LIBTCC),"$(libdir)")
@@ -487,6 +501,8 @@ help: · 129 unmodified lines
487501 @echo " LIB-i386 = {B}/i386-linux/lib:{B}/i386-linux/usr/lib"
488502 @echo " INC-i386 = {B}/lib/include:{B}/i386-linux/usr/include"
489503 @echo " DEF-i386 += -D__linux__"
504+ @echo " Or to configure a cross compiler for system-files in /usr/<triplet>"
505+ @echo " TRIPLET-arm-eabi = arm-linux-gnueabi"
490506
491507 # --------------------------------------------------------------------------
492508 endif # ($(INCLUDED),no)
config-extra.mak.example+0−27
@@ -1,27 +0,0 @@
1−#
2−# during 'make', this file is included from the tcc Makefile
3−#
4−# this is an example, how to help tcc to find
5−# the c library and the startup files for cross compiling.
6−#
7−# we expect here, that the GNU libc is used and that the related development files
8−# are installed in a subdirectory with the target triplet used by gcc
9−#
10−
11−# set CONFIG_TRIPLET for cross compiler targets
12−DEF-i386+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"i386-linux-gnu\" "
13−DEF-x86_64+=-UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"x86_64-linux-gnu\" "
14−
15−# many api/fp combinations are possible for arm
16−DEF-arm+=-UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"arm-linux-gnueabihf\" "
17−DEF-arm64+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"aarch64-linux-gnu\" "
18−
19−DEF-riscv64+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"riscv64-linux-gnu\" "
20−# For win32/win64 targets, we expect mingw 64
21−# is is for additional packes, as tcc has ist own win32 startfiles
22−DEF-i386-win32+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"i686-w64-mingw32\" "
23−DEF-x86_64-win32+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"x86_64-w64-mingw32\" "
24−
25−# is a free cross compile toolchain for macos available?
26−#DEF-x86_64-osx+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"x86_64-apple-darwin\" "
27−#DEF-arm64-osx+= -UCONFIG_TRIPLET -DCONFIG_TRIPLET="\"aarch64-apple-darwin\" "
tcc.h+1−7
@@ -260,9 +260,7 @@ extern long double strtold (const char *__nptr, char **__endptr); · 259 unmodified lines
260260
261261 /* path to find crt1.o, crti.o and crtn.o */
262262 #ifndef CONFIG_TCC_CRTPREFIX
263−# define CONFIG_TCC_CRTPREFIX \
264− ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
265− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib"
263+# define CONFIG_TCC_CRTPREFIX USE_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR)
266264 #endif
267265
268266 #ifndef CONFIG_USR_INCLUDE
@@ -279,8 +277,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 10 unmodified lines
279277 # define CONFIG_TCC_SYSINCLUDEPATHS \
280278 "{B}/include" \
281279 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/include") \
282− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/include" \
283− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/include" \
284280 ":" ALSO_TRIPLET(CONFIG_SYSROOT CONFIG_USR_INCLUDE)
285281 # endif
286282 #endif
@@ -293,8 +289,6 @@ extern long double strtold (const char *__nptr, char **__endptr); · 6 unmodified lines
293289 # define CONFIG_TCC_LIBPATHS \
294290 "{B}" \
295291 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/" CONFIG_LDDIR) \
296− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr") "/lib" \
297− ":" USE_TRIPLET(CONFIG_SYSROOT "/usr/local") "/lib" \
298292 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/" CONFIG_LDDIR) \
299293 ":" ALSO_TRIPLET(CONFIG_SYSROOT "/usr/local/" CONFIG_LDDIR)
300294 # endif

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t