Skip to content

Commit 6daf161

Browse files
author
grischka
committed
configure & tcc.h: include & lib searchpath cleanup
configure: - remove CONFIG_USE_LIBGCC, --with-libgcc - remove CONFIG_LDDIR - remove CONFIG_USR_INCLUDE - add -q switch for quiet (=no) output tcc.h: - remove /usr/local/include&lib search paths arm-gen.c: - remove default_elfinterp() function tccelf.c: - setup the ELF-interp in tccelf_new()
1 parent 923fba8 commit 6daf161

8 files changed

Lines changed: 97 additions & 122 deletions

File tree

Makefile

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -158,47 +158,45 @@ all : cross
158158
endif
159159

160160
# --------------------------------------------
161-
162-
T = $(or $(CROSS_TARGET),$(NATIVE_TARGET),unknown)
161+
T = $(or $(CROSS_TARGET),$(NATIVE_TARGET))
163162
X = $(if $(CROSS_TARGET),$(CROSS_TARGET)-)
164163

164+
ifneq ($(T),$(NATIVE_TARGET))
165+
$(if $(DEF-$T),,$(error error: unknown target: '$T'))
166+
ifneq ($(CONFIG_WIN32),yes)
167+
DEF-win = -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
168+
endif
169+
# some default config for cross compilers
170+
TRIPLET-i386 = i686-linux-gnu
171+
TRIPLET-x86_64 = x86_64-linux-gnu
172+
TRIPLET-arm = arm-linux-gnueabihf
173+
TRIPLET-arm64 = aarch64-linux-gnu
174+
TRIPLET-riscv64 = riscv64-linux-gnu
175+
ifneq ($(TRIPLET-$T),)
176+
# assume support files in "/usr/<triplet>"
177+
ROOT-$T = /usr/$(TRIPLET-$T)
178+
INC-$T = {B}/include:{R}/include
179+
LIB-$T = {R}/lib:{B}
180+
CRT-$T = {R}/lib
181+
endif
165182
DEFINES += $(DEF-$T)
166183
DEFINES += $(if $(ROOT-$T),-DCONFIG_SYSROOT="\"$(ROOT-$T)\"")
167184
DEFINES += $(if $(CRT-$T),-DCONFIG_TCC_CRTPREFIX="\"$(CRT-$T)\"")
168185
DEFINES += $(if $(LIB-$T),-DCONFIG_TCC_LIBPATHS="\"$(LIB-$T)\"")
169186
DEFINES += $(if $(INC-$T),-DCONFIG_TCC_SYSINCLUDEPATHS="\"$(INC-$T)\"")
170187
DEFINES += $(if $(ELF-$T),-DCONFIG_TCC_ELFINTERP="\"$(ELF-$T)\"")
171188
DEFINES += $(DEF-$(or $(findstring win,$T),unx))
172-
173-
ifneq ($(X),)
174-
$(if $(DEF-$T),,$(error error: unknown target: '$T'))
175-
DEF-$(NATIVE_TARGET) =
176-
DEF-$T += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
177-
ifneq ($(CONFIG_WIN32),yes)
178-
DEF-win += -DCONFIG_TCCDIR="\"$(tccdir)/win32\""
179-
endif
180-
else
181-
# using values from config.h
182-
DEF-$(NATIVE_TARGET) =
189+
DEFINES += -DCONFIG_TCC_CROSSPREFIX="\"$X\""
183190
endif
184191

185192
# include custom configuration (see make help)
186193
-include config-extra.mak
187194

188-
ifneq ($(T),$(NATIVE_TARGET))
189-
# assume support files for cross-targets in "/usr/<triplet>" by default
190-
TRIPLET-i386 ?= i686-linux-gnu
191-
TRIPLET-x86_64 ?= x86_64-linux-gnu
192-
TRIPLET-arm ?= arm-linux-gnueabi
193-
TRIPLET-arm64 ?= aarch64-linux-gnu
194-
TRIPLET-riscv64 ?= riscv64-linux-gnu
195-
MARCH-i386 ?= i386-linux-gnu
196-
MARCH-$T ?= $(TRIPLET-$T)
197-
TR = $(if $(TRIPLET-$T),$T,ignored)
198-
CRT-$(TR) ?= /usr/$(TRIPLET-$T)/lib
199-
LIB-$(TR) ?= {B}:/usr/$(TRIPLET-$T)/lib:/usr/lib/$(MARCH-$T)
200-
INC-$(TR) ?= {B}/include:/usr/$(TRIPLET-$T)/include:/usr/include
201-
endif
195+
# so one can use: make EXTRA-DEFS=...
196+
DEFINES += $(EXTRA-DEFS)
197+
198+
# find config.h with 'out of tree' builds
199+
DEFINES += -I$(TOP)
202200

203201
CORE_FILES = tcc.c tcctools.c libtcc.c tccpp.c tccgen.c tccdbg.c tccelf.c tccasm.c tccrun.c
204202
CORE_FILES += tcc.h config.h libtcc.h tcctok.h
@@ -209,7 +207,6 @@ x86_64-win32_FILES = $(x86_64_FILES) tccpe.c
209207
x86_64-osx_FILES = $(x86_64_FILES) tccmacho.c
210208
arm_FILES = $(CORE_FILES) arm-gen.c arm-link.c arm-asm.c arm-tok.h
211209
arm-wince_FILES = $(arm_FILES) tccpe.c
212-
arm-eabihf_FILES = $(arm_FILES)
213210
arm-fpa_FILES = $(arm_FILES)
214211
arm-fpa-ld_FILES = $(arm_FILES)
215212
arm-vfp_FILES = $(arm_FILES)
@@ -241,7 +238,6 @@ $(CROSS_TARGET)-tcc.o : DEFINES += -DONE_SOURCE=0
241238
endif
242239
# native tcc always made from tcc.o and libtcc.[so|a]
243240
tcc.o : DEFINES += -DONE_SOURCE=0
244-
DEFINES += -I$(TOP)
245241

246242
GITHASH:=$(shell git rev-parse --abbrev-ref HEAD 2>/dev/null || echo no)
247243
ifneq ($(GITHASH),no)
@@ -340,7 +336,7 @@ FORCE:
340336
# some versions of gnu-make do not recognize 'command' as a shell builtin
341337
WHICH = sh -c 'command -v $1'
342338

343-
run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2)
339+
run-if = $(if $(shell $(call WHICH,$1)),$S $1 $2,@echo "(skipping $@ - no $1)")
344340
S = $(if $(findstring yes,$(SILENT)),@$(info * $@))
345341

346342
# --------------------------------------------------------------------------
@@ -501,14 +497,14 @@ distclean: clean
501497
help:
502498
@echo "make"
503499
@echo " build native compiler (from separate objects)"
504-
@echo "make cross"
505-
@echo " build cross compilers (from one source)"
506500
@echo "make ONE_SOURCE=no/yes SILENT=no/yes"
507501
@echo " force building from separate/one object(s), less/more silently"
508502
@echo "make cross-TARGET"
509503
@echo " build one specific cross compiler for 'TARGET'. Currently supported:"
510504
@echo " $(wordlist 1,8,$(TCC_X))"
511505
@echo " $(wordlist 9,99,$(TCC_X))"
506+
@echo "make cross"
507+
@echo " build all cross compilers"
512508
@echo "make test"
513509
@echo " run all tests"
514510
@echo "make tests2.all / make tests2.37 / make tests2.37+"

arm-gen.c

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,8 @@ enum {
133133

134134
#define CHAR_IS_UNSIGNED
135135

136-
#ifdef TCC_ARM_HARDFLOAT
137-
# define ARM_FLOAT_ABI ARM_HARD_FLOAT
138-
#else
139-
# define ARM_FLOAT_ABI ARM_SOFTFP_FLOAT
140-
#endif
136+
#define ARM_SOFTFP_FLOAT 0
137+
#define ARM_HARD_FLOAT 1
141138

142139
/******************************************************/
143140
#else /* ! TARGET_DEFS_ONLY */
@@ -160,8 +157,6 @@ ST_DATA const char * const target_machine_defs =
160157
#endif
161158
;
162159

163-
enum float_abi float_abi;
164-
165160
ST_DATA const int reg_classes[NB_REGS] = {
166161
/* r0 */ RC_INT | RC_R0,
167162
/* r1 */ RC_INT | RC_R1,
@@ -180,6 +175,7 @@ ST_DATA const int reg_classes[NB_REGS] = {
180175
#endif
181176
};
182177

178+
static int float_abi;
183179
static int func_sub_sp_offset, last_itod_magic;
184180
static int leaffunc;
185181

@@ -241,16 +237,6 @@ static int regmask(int r) {
241237

242238
/******************************************************/
243239

244-
#if defined(TCC_ARM_EABI) && !defined(CONFIG_TCC_ELFINTERP)
245-
const char *default_elfinterp(struct TCCState *s)
246-
{
247-
if (s->float_abi == ARM_HARD_FLOAT)
248-
return "/lib/ld-linux-armhf.so.3";
249-
else
250-
return "/lib/ld-linux.so.3";
251-
}
252-
#endif
253-
254240
void o(uint32_t i)
255241
{
256242
/* this is a good place to start adding big-endian support*/

arm-link.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@
1818
#define PCRELATIVE_DLLPLT 1
1919
#define RELOCATE_DLLPLT 1
2020

21-
enum float_abi {
22-
ARM_SOFTFP_FLOAT,
23-
ARM_HARD_FLOAT,
24-
};
25-
2621
#else /* !TARGET_DEFS_ONLY */
2722

2823
#include "tcc.h"

configure

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ mingw32="no"
3535
LIBSUF=".a"
3636
EXESUF=""
3737
DLLSUF=".so"
38-
tcc_usrinclude=""
3938
tcc_sysincludepaths=""
4039
tcc_libpaths=""
4140
tcc_crtprefix=""
4241
tcc_elfinterp=""
4342
triplet=
44-
tcc_lddir=
4543
confvars=
4644
suggest="yes"
4745
gcc_major=0
@@ -53,6 +51,7 @@ cpuver=
5351
dwarf=
5452
targetos=
5553
build_cross=
54+
quiet=
5655

5756
# use CC/AR from environment when set
5857
test -n "$CC" && cc="$CC"
@@ -160,8 +159,6 @@ for opt do
160159
;;
161160
--debug) confvars_set debug
162161
;;
163-
--with-libgcc) confvars_set libgcc
164-
;;
165162
--with-selinux) confvars_set selinux
166163
;;
167164
--tcc-switches=*) assign_opt "$opt" tcc_switches
@@ -174,6 +171,8 @@ for opt do
174171
;;
175172
--help|-h) show_help="yes"
176173
;;
174+
-q) quiet=yes
175+
;;
177176
*) echo "configure: WARNING: unrecognized option $opt"
178177
;;
179178
esac
@@ -197,6 +196,7 @@ Standard options:
197196
--docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]
198197
--mandir=DIR man documentation in DIR [SHAREDIR/man]
199198
--infodir=DIR info documentation in DIR [SHAREDIR/info]
199+
-q be quiet
200200
201201
Advanced options (experts only):
202202
--source-path=PATH path of source code [$source_path]
@@ -210,9 +210,8 @@ Advanced options (experts only):
210210
--disable-static make libtcc.so instead of libtcc.a
211211
--enable-static make libtcc.a instead of libtcc.dll (win32)
212212
--disable-rpath disable use of -rpath with libtcc.so
213-
--with-libgcc use libgcc_s.so.1 instead of libtcc1.a
214213
--with-selinux use mmap for executable memory (tcc -run)
215-
--enable-cross build cross compilers (see also 'make help')
214+
--enable-cross build all cross compilers (see also 'make help')
216215
217216
--sysincludepaths=... specify system include paths, colon separated
218217
--libpaths=... specify system library paths, colon separated
@@ -367,6 +366,7 @@ case $targetos in
367366
cc=`command -v cc`
368367
cc=`readlink $cc || echo clang`
369368
tcc_usrinclude="`xcrun --show-sdk-path`/usr/include"
369+
default tcc_sysincludepaths "{B}/include:$tcc_usrinclude"
370370
if test "${confvars%new_macho*}" = "${confvars}"; then
371371
# if new_macho was not specified and (known) ver <= 10, use old (=no)
372372
osxver=$(sw_vers -productVersion 2>/dev/null) # X.Y.Z
@@ -478,7 +478,8 @@ if test -z "$build_cross"; then
478478
if test -z "$triplet"; then
479479
case $cpu in x86_64|arm64|riscv64)
480480
if test -f "/usr/lib64/crti.o" ; then
481-
tcc_lddir="lib64"
481+
default tcc_libpaths "{B}:/usr/lib64"
482+
default tcc_crtprefix "/usr/lib64"
482483
fi
483484
esac
484485
fi
@@ -552,6 +553,7 @@ fi
552553

553554
fcho() { if test -n "$2"; then echo "$1$2"; fi }
554555

556+
if test -z "$quiet"; then
555557
fcho "Binary directory " "$bindir"
556558
fcho "TinyCC directory " "$tccdir"
557559
fcho "Library directory " "$libdir"
@@ -560,7 +562,6 @@ fcho "Manual directory " "$mandir"
560562
fcho "Info directory " "$infodir"
561563
fcho "Doc directory " "$docdir"
562564
fcho "Target root prefix " "$sysroot"
563-
fcho "/usr/include dir " "$tcc_usrinclude"
564565
echo "Source path $source_path"
565566
echo "Build OS $(uname -m -s)"
566567
echo "C compiler $cc ($gcc_major.$gcc_minor)"
@@ -574,6 +575,7 @@ fcho "Elfinterp " "$tcc_elfinterp"
574575
fcho "Switches " "$tcc_switches"
575576
fcho "Config " "${confvars# }"
576577
echo "Creating config.mak and config.h"
578+
fi
577579

578580
version=$(head "$source_path/VERSION")
579581

@@ -691,7 +693,6 @@ for v in $cpu $confvars ; do
691693
esac
692694
;;
693695
# other
694-
CONFIG_libgcc=yes) print_num CONFIG_USE_LIBGCC 1 ;;
695696
CONFIG_selinux=yes) print_num CONFIG_SELINUX 1 ;;
696697
CONFIG_pie=yes) print_num CONFIG_TCC_PIE 1 ;;
697698
CONFIG_pic=yes) print_num CONFIG_TCC_PIC 1 ;;
@@ -706,13 +707,11 @@ for v in $cpu $confvars ; do
706707
esac
707708
done
708709

709-
print_str CONFIG_USR_INCLUDE "$tcc_usrinclude"
710710
print_str CONFIG_TCC_SYSINCLUDEPATHS "$tcc_sysincludepaths"
711711
print_str CONFIG_TCC_LIBPATHS "$tcc_libpaths"
712712
print_str CONFIG_TCC_CRTPREFIX "$tcc_crtprefix"
713713
print_str CONFIG_TCC_ELFINTERP "$tcc_elfinterp"
714714
print_str CONFIG_TCC_SWITCHES "$tcc_switches"
715-
print_str CONFIG_LDDIR "$tcc_lddir"
716715
print_str CONFIG_TRIPLET "$triplet"
717716
print_str CONFIG_OS_RELEASE "$os_release"
718717
echo "#endif" >> $TMPH && echo >> $TMPH
@@ -724,7 +723,7 @@ print_num CONFIG_TCC_PREDEFS "$predefs"
724723
diff $TMPH config.h >/dev/null 2>&1
725724
if test $? -ne 0 ; then
726725
mv -f $TMPH config.h
727-
else
726+
elif test -z "$quiet"; then
728727
echo "config.h is unchanged"
729728
fi
730729

0 commit comments

Comments
 (0)