History

Add a --multiarch-triplet switch to configure

Add a --multiarch-triplet switch to configure. The switch will allow files to be search for each default path in path/<triplet> and then path. Default paths handled that way: - CONFIG_TCC_SYSINCLUDE_PATHS - CONFIG_TCC_LIBPATH - path to crt*.o - path to libgcc_s.so.1 Path missing: elf interpreter path (will be handled in another commit)

Thomas Preud'homme committed 15 years ago

Commit 76adc571 parent 5e954fe4 files · +153 −74Browse files

Unified · Split

4 files
  1. configure +124 −35
  2. libtcc.c +18 −6
  3. tcc.h +3 −31
  4. tccelf.c +8 −2
configure+124−35
@@ -31,6 +31,7 @@ includedir="" · 30 unmodified lines
31mandir=""31mandir=""
32infodir=""32infodir=""
33sysroot=""33sysroot=""
34multiarch_triplet=""
34cross_prefix=""35cross_prefix=""
35cc="gcc"36cc="gcc"
36host_cc="gcc"37host_cc="gcc"
@@ -120,6 +121,8 @@ for opt do · 83 unmodified lines
120 ;;121 ;;
121 --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`122 --sysroot=*) sysroot=`echo $opt | cut -d '=' -f 2`
122 ;;123 ;;
124 --multiarch-triplet=*) multiarch_triplet=`echo $opt | cut -d '=' -f 2`
125 ;;
123 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`126 --source-path=*) source_path=`echo $opt | cut -d '=' -f 2`
124 ;;127 ;;
125 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`128 --cross-prefix=*) cross_prefix=`echo $opt | cut -d '=' -f 2`
@@ -235,36 +238,37 @@ Options: [defaults in brackets after descriptions] · 109 unmodified lines
235 238
236EOF239EOF
237echo "Standard options:"240echo "Standard options:"
238echo " --help print this message"241echo " --help print this message"
239echo " --prefix=PREFIX install in PREFIX [$prefix]"242echo " --prefix=PREFIX install in PREFIX [$prefix]"
240echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"243echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
241echo " [same as prefix]"244echo " [same as prefix]"
242echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"245echo " --bindir=DIR user executables in DIR [EPREFIX/bin]"
243echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"246echo " --libdir=DIR object code libraries in DIR [EPREFIX/lib]"
244echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"247echo " --tccdir=DIR installation directory [EPREFIX/lib/tcc]"
245echo " --includedir=DIR C header files in DIR [PREFIX/include]"248echo " --includedir=DIR C header files in DIR [PREFIX/include]"
246echo " --sharedir=DIR documentation root DIR [PREFIX]/share"249echo " --sharedir=DIR documentation root DIR [PREFIX]/share"
247echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"250echo " --docdir=DIR documentation in DIR [SHAREDIR/doc/tcc]"
248echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"251echo " --mandir=DIR man documentation in DIR [SHAREDIR/man]"
249echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"252echo " --infodir=DIR info documentation in DIR [SHAREDIR/info]"
250echo ""253echo ""
251echo "Advanced options (experts only):"254echo "Advanced options (experts only):"
252echo " --source-path=PATH path of source code [$source_path]"255echo " --source-path=PATH path of source code [$source_path]"
253echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"256echo " --cross-prefix=PREFIX use PREFIX for compile tools [$cross_prefix]"
254echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"257echo " --sysroot=PREFIX prepend PREFIX to library/include paths []"
255echo " --cc=CC use C compiler CC [$cc]"258echo " --multiarch-triplet=SUFFIX append SUFFIX to library/include paths []"
256echo " --disable-static make libtcc.so instead of libtcc.a"259echo " --cc=CC use C compiler CC [$cc]"
257echo " --disable-rpath disable use of -rpath with the above"260echo " --disable-static make libtcc.so instead of libtcc.a"
258echo " --strip-binaries strip symbol tables from resulting binaries"261echo " --disable-rpath disable use of -rpath with the above"
259echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"262echo " --strip-binaries strip symbol tables from resulting binaries"
260echo " --enable-mingw32 build windows version on linux with mingw32"263echo " --with-libgcc use /lib/libgcc_s.so.1 instead of libtcc.a"
261echo " --enable-cygwin build windows version on windows with cygwin"264echo " --enable-mingw32 build windows version on linux with mingw32"
262echo " [requires cygwin and mingw32-make]"265echo " --enable-cygwin build windows version on windows with cygwin"
263echo " --enable-cross build cross compilers"266echo " [requires cygwin and mingw32-make]"
264echo " --extra-cflags= extra compiler flags"267echo " --enable-cross build cross compilers"
265echo " --extra-ldflags= extra linker options"268echo " --extra-cflags= extra compiler flags"
266echo " --with-selinux use mmap instead of exec mem"269echo " --extra-ldflags= extra linker options"
267echo " [requires write access to /tmp]"270echo " --with-selinux use mmap instead of exec mem"
271echo " [requires write access to /tmp]"
268echo ""272echo ""
269#echo "NOTE: The object files are build at the place where configure is launched"273#echo "NOTE: The object files are build at the place where configure is launched"
270exit 1274exit 1
@@ -330,13 +334,14 @@ echo "Manual directory $mandir" · 59 unmodified lines
330echo "Info directory $infodir"334echo "Info directory $infodir"
331echo "Doc directory $docdir"335echo "Doc directory $docdir"
332echo "Target root prefix $sysroot"336echo "Target root prefix $sysroot"
333echo "Source path $source_path"337echo "Multiarch triplet $multiarch_triplet"
334echo "C compiler $cc"338echo "Source path $source_path"
335echo "CPU $cpu"339echo "C compiler $cc"
336echo "Big Endian $bigendian"340echo "CPU $cpu"
337echo "gprof enabled $gprof"341echo "Big Endian $bigendian"
338echo "cross compilers $build_cross"342echo "gprof enabled $gprof"
339echo "use libgcc $use_libgcc"343echo "cross compilers $build_cross"
344echo "use libgcc $use_libgcc"
340 345
341echo "Creating config.mak and config.h"346echo "Creating config.mak and config.h"
342 347
@@ -356,9 +361,93 @@ echo "docdir=\$(DESTDIR)$docdir" >> config.mak · 13 unmodified lines
356echo "#ifndef CONFIG_SYSROOT" >> $TMPH361echo "#ifndef CONFIG_SYSROOT" >> $TMPH
357echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH362echo "#define CONFIG_SYSROOT \"$sysroot\"" >> $TMPH
358echo "#endif" >> $TMPH363echo "#endif" >> $TMPH
364echo "" >> $TMPH
365
366# Set default include and library paths
367win_incpaths="\\\b/include;\\\b/include/winapi"
368unix_incpaths="/usr/local/include:/usr/include:\\\b/include"
369win_libpaths="\\\b/lib"
370unix_libpaths="CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX"
371unix_libpaths="$unix_libpaths\":\"CONFIG_SYSROOT CONFIG_TCC_LDDIR"
372unix_libpaths="$unix_libpaths\":\"CONFIG_SYSROOT \"/usr/local\" CONFIG_TCC_LDDIR"
373
374# sep: path separator in paths
375# tmp: paths multiarchified (one path per line)
376# q: quote (if sep contains ")
377# r: carriage return pattern (if sep contains ")
378# s: space (if sep contains ")
379multiarchify()
380{
381 local sep tmp
382
383 paths="$1"
384 sep="$2"
385 tmp=""
386 q=""
387 r=""
388 s=""
389 if [ -z "${sep%%\"*}" ] ; then
390 q="\""
391 r=" \\\\\n "
392 s=" "
393 fi
394 paths="$paths$sep"
395 while test -n "$paths" ; do
396 tmp="$tmp${tmp:+$r$sep$s}${paths%%$sep*}$s$q/$multiarch_triplet$q"
397 tmp="$tmp$r$sep$s${paths%%$sep*}"
398 paths="${paths#*$sep}"
399 done
400 paths="$tmp"
401}
402
403if test -n "$multiarch_triplet" ; then
404 multiarchify "$win_incpaths" ";"
405 win_incpaths="\"$paths\""
406 multiarchify "$unix_incpaths" ":"
407 unix_incpaths="\"$paths\""
408 multiarchify "$win_libpaths" ";"
409 win_libpaths="\"$paths\""
410 multiarchify "$unix_libpaths" "\":\""
411 unix_libpaths="$paths"
412 echo "#define CONFIG_TCC_MULTIARCH_TRIPLET \"$multiarch_triplet\"" >> $TMPH
413fi
414
415echo "#ifndef CONFIG_TCC_LDDIR" >> $TMPH
416echo " #if defined(TCC_TARGET_X86_64_CENTOS)" >> $TMPH
417echo " #define CONFIG_TCC_LDDIR \"/lib64\"" >> $TMPH
418echo " #else" >> $TMPH
419echo " #define CONFIG_TCC_LDDIR \"/lib\"" >> $TMPH
420echo " #endif" >> $TMPH
421echo "#endif" >> $TMPH
422echo "" >> $TMPH
423
424echo "/* path to find crt1.o, crti.o and crtn.o */" >> $TMPH
425echo "#ifndef CONFIG_TCC_CRT_PREFIX" >> $TMPH
426echo "# define CONFIG_TCC_CRT_PREFIX \"/usr\" CONFIG_TCC_LDDIR" >> $TMPH
427echo "#endif" >> $TMPH
428echo "" >> $TMPH
429
430echo "#ifndef CONFIG_TCC_SYSINCLUDE_PATHS" >> $TMPH
431echo "# ifdef TCC_TARGET_PE" >> $TMPH
432echo "# define CONFIG_TCC_SYSINCLUDE_PATHS $win_incpaths" >> $TMPH
433echo "# else" >> $TMPH
434echo "# define CONFIG_TCC_SYSINCLUDE_PATHS $unix_incpaths" >> $TMPH
435echo "# endif" >> $TMPH
436echo "#endif" >> $TMPH
437echo "" >> $TMPH
438echo "#ifndef CONFIG_TCC_LIBPATH" >> $TMPH
439echo "# ifdef TCC_TARGET_PE" >> $TMPH
440echo "# define CONFIG_TCC_LIBPATH $win_libpaths" >> $TMPH
441echo "# else" >> $TMPH
442echo "# define CONFIG_TCC_LIBPATH $unix_libpaths" >> $TMPH
443echo "# endif" >> $TMPH
444echo "#endif" >> $TMPH
445echo "" >> $TMPH
446
359echo "#ifndef CONFIG_TCCDIR" >> $TMPH447echo "#ifndef CONFIG_TCCDIR" >> $TMPH
360echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH448echo "#define CONFIG_TCCDIR \"$tccdir\"" >> $TMPH
361echo "#endif" >> $TMPH449echo "#endif" >> $TMPH
450echo "" >> $TMPH
362echo "CC=$cc" >> config.mak451echo "CC=$cc" >> config.mak
363echo "GCC_MAJOR=$gcc_major" >> config.mak452echo "GCC_MAJOR=$gcc_major" >> config.mak
364echo "#define GCC_MAJOR $gcc_major" >> $TMPH453echo "#define GCC_MAJOR $gcc_major" >> $TMPH
libtcc.c+18−6
@@ -1226,14 +1226,19 @@ the_end: · 1225 unmodified lines
1226 return ret;1226 return ret;
1227}1227}
1228 1228
1229LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename)1229static int tcc_add_file_noerror(TCCState *s, const char *filename, int extra_flags)
1230{1230{
1231 dynarray_add((void ***)&s->input_files, &s->nb_input_files, tcc_strdup(filename));1231 dynarray_add((void ***)&s->input_files, &s->nb_input_files, tcc_strdup(filename));
1232 1232
1233 if (s->output_type == TCC_OUTPUT_PREPROCESS)1233 if (s->output_type == TCC_OUTPUT_PREPROCESS)
1234 return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR | AFF_PREPROCESS);1234 return tcc_add_file_internal(s, filename, extra_flags | AFF_PREPROCESS);
1235 else1235 else
1236 return tcc_add_file_internal(s, filename, AFF_PRINT_ERROR);1236 return tcc_add_file_internal(s, filename, extra_flags);
1237}
1238
1239LIBTCCAPI int tcc_add_file(TCCState *s, const char *filename)
1240{
1241 return tcc_add_file_noerror(s, filename, AFF_PRINT_ERROR);
1237}1242}
1238 1243
1239LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname)1244LIBTCCAPI int tcc_add_library_path(TCCState *s, const char *pathname)
@@ -1347,9 +1352,16 @@ LIBTCCAPI int tcc_set_output_type(TCCState *s, int output_type) · 107 unmodified lines
1347#else1352#else
1348 if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&1353 if ((output_type == TCC_OUTPUT_EXE || output_type == TCC_OUTPUT_DLL) &&
1349 !s->nostdlib) {1354 !s->nostdlib) {
1350 if (output_type != TCC_OUTPUT_DLL)1355 if (output_type != TCC_OUTPUT_DLL) {
1351 tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crt1.o");1356#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
1352 tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crti.o");1357 if (tcc_add_file_noerror(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/" CONFIG_TCC_MULTIARCH_TRIPLET "/crt1.o", 0))
1358#endif
1359 tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crt1.o");
1360 }
1361#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
1362 if (tcc_add_file_noerror(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/" CONFIG_TCC_MULTIARCH_TRIPLET "/crti.o", 0))
1363#endif
1364 tcc_add_file(s, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crti.o");
1353 }1365 }
1354#endif1366#endif
1355 return 0;1367 return 0;
tcc.h+3−31
@@ -139,37 +139,9 @@ · 138 unmodified lines
139#define true 1139#define true 1
140typedef int BOOL;140typedef int BOOL;
141 141
142#ifndef CONFIG_TCC_LDDIR142/* See definition of default values of CONFIG_TCC_LDDIR, CONFIG_TCC_CRT_PREFIX,
143 #if defined(TCC_TARGET_X86_64_CENTOS)143 CONFIG_TCC_SYSINCLUDE_PATHS and CONFIG_TCC_LIBPATH in config.h or configure
144 #define CONFIG_TCC_LDDIR "/lib64"144 */
145 #else
146 #define CONFIG_TCC_LDDIR "/lib"
147 #endif
148#endif
149
150/* path to find crt1.o, crti.o and crtn.o */
151#ifndef CONFIG_TCC_CRT_PREFIX
152# define CONFIG_TCC_CRT_PREFIX "/usr" CONFIG_TCC_LDDIR
153#endif
154
155#ifndef CONFIG_TCC_SYSINCLUDE_PATHS
156# ifdef TCC_TARGET_PE
157# define CONFIG_TCC_SYSINCLUDE_PATHS "\b/include;\b/include/winapi"
158# else
159# define CONFIG_TCC_SYSINCLUDE_PATHS "/usr/local/include:/usr/include:\b/include"
160# endif
161#endif
162
163#ifndef CONFIG_TCC_LIBPATH
164# ifdef TCC_TARGET_PE
165# define CONFIG_TCC_LIBPATH "\b/lib"
166# else
167# define CONFIG_TCC_LIBPATH \
168 CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX \
169 ":" CONFIG_SYSROOT CONFIG_TCC_LDDIR \
170 ":" CONFIG_SYSROOT "/usr/local" CONFIG_TCC_LDDIR
171# endif
172#endif
173 145
174#define INCLUDE_STACK_SIZE 32146#define INCLUDE_STACK_SIZE 32
175#define IFDEF_STACK_SIZE 64147#define IFDEF_STACK_SIZE 64
tccelf.c+8−2
@@ -1238,7 +1238,10 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 1237 unmodified lines
1238 if (!s1->nostdlib) {1238 if (!s1->nostdlib) {
1239#ifdef CONFIG_USE_LIBGCC1239#ifdef CONFIG_USE_LIBGCC
1240 tcc_add_library(s1, "c");1240 tcc_add_library(s1, "c");
1241 tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_LDDIR"/libgcc_s.so.1");1241#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
1242 if (tcc_add_file_internal(s1, CONFIG_SYSROOT CONFIG_TCC_LDDIR "/" CONFIG_TCC_MULTIARCH_TRIPLET "/libgcc_s.so.1", 0))
1243#endif
1244 tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_LDDIR"/libgcc_s.so.1");
1242#else1245#else
1243 tcc_add_library(s1, "c");1246 tcc_add_library(s1, "c");
1244#ifndef WITHOUT_LIBTCC1247#ifndef WITHOUT_LIBTCC
@@ -1252,7 +1255,10 @@ ST_FUNC void tcc_add_runtime(TCCState *s1) · 7 unmodified lines
1252 }1255 }
1253 /* add crt end if not memory output */1256 /* add crt end if not memory output */
1254 if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) {1257 if (s1->output_type != TCC_OUTPUT_MEMORY && !s1->nostdlib) {
1255 tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crtn.o");1258#ifdef CONFIG_TCC_MULTIARCH_TRIPLET
1259 if (tcc_add_file_internal(s1, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/" CONFIG_TCC_MULTIARCH_TRIPLET "/crtn.o", 0))
1260#endif
1261 tcc_add_file(s1, CONFIG_SYSROOT CONFIG_TCC_CRT_PREFIX "/crtn.o");
1256 }1262 }
1257}1263}
1258 1264

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