Skip to content

Commit e5eedc0

Browse files
author
grischka
committed
Revert "tcc.h: Extend search path for include, lib and crt"
This reverts commit 2507c71. 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
1 parent e41730f commit e5eedc0

File tree

3 files changed

+19
-36
lines changed

3 files changed

+19
-36
lines changed

Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")
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
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))
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
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:
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

Lines changed: 0 additions & 27 deletions
This file was deleted.

tcc.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ extern long double strtold (const char *__nptr, char **__endptr);
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);
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);
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

0 commit comments

Comments
 (0)