From 160633c62690e70e5af6bad15c3e0ccab8b59578 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Mon, 25 Jul 2005 19:42:04 +0000 Subject: gcc.c (option_map): Add --sysroot. * gcc.c (option_map): Add --sysroot. (process_command): Handle --sysroot. (display_help): Document it. * doc/cppopts.tex (-isysroot): Document. * doc/invoke.texi (--sysroot): Document. * doc/install.texi (--with-build-sysroot): Document. * Makefile.in (inhibit_libc): New variable. (INHIBIT_LIBC_CFLAGS): Likewise. (LIBGCC2_CFLAGS): Include $(INHIBIT_LIBC_CFLAGS). (CRTSTUFF_CFLAGS): Include $(INHIBIT_LIBC_CFLAGS). ($(T)crtbegin.o): Do not use @inhibit_libc@. ($(T)crtend.o): Likewise. ($(T)crtbeginS.o): Do not use @inhibit_libc@. ($(T)crtendS.o): Likewise. ($(T)crtbeginT.o): Do not use @inhibit_libc@. ($(T)crtendT.o): Likewise. (stmp-fixinc): Do not complain about missing headers if inhibit_libc. * configure.ac (inhibit_libc): Set it to true/false. (--with-build-sysroot): New option. Use it to set SYSTEM_HEADER_DIR. * configure: Regenerated. From-SVN: r102367 --- gcc/ChangeLog | 27 +++++++++++++++++++++++++++ gcc/Makefile.in | 27 ++++++++++++++++++--------- gcc/configure | 28 +++++++++++++++++++++------- gcc/configure.ac | 17 +++++++++++++---- gcc/doc/cppopts.texi | 5 +++++ gcc/doc/install.texi | 10 ++++++++++ gcc/doc/invoke.texi | 20 +++++++++++++++++++- gcc/gcc.c | 9 +++++++++ 8 files changed, 122 insertions(+), 21 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8df4291..7d8d6f7 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,30 @@ +2005-07-25 Mark Mitchell + + * gcc.c (option_map): Add --sysroot. + (process_command): Handle --sysroot. + (display_help): Document it. + * doc/cppopts.tex (-isysroot): Document. + * doc/invoke.texi (--sysroot): Document. + * doc/install.texi (--with-build-sysroot): Document. + + * Makefile.in (inhibit_libc): New variable. + (INHIBIT_LIBC_CFLAGS): Likewise. + (LIBGCC2_CFLAGS): Include + $(INHIBIT_LIBC_CFLAGS). + (CRTSTUFF_CFLAGS): Include $(INHIBIT_LIBC_CFLAGS). + ($(T)crtbegin.o): Do not use @inhibit_libc@. + ($(T)crtend.o): Likewise. + ($(T)crtbeginS.o): Do not use @inhibit_libc@. + ($(T)crtendS.o): Likewise. + ($(T)crtbeginT.o): Do not use @inhibit_libc@. + ($(T)crtendT.o): Likewise. + (stmp-fixinc): Do not complain about missing headers if + inhibit_libc. + * configure.ac (inhibit_libc): Set it to true/false. + (--with-build-sysroot): New option. Use it to set + SYSTEM_HEADER_DIR. + * configure: Regenerated. + 2005-07-25 Manfred Hollstein * calls.c (store_one_arg): Fix unsigned comparison warning. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 30b95ee..55b6e74 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -325,7 +325,7 @@ GCC_FOR_TARGET = $(STAGE_CC_WRAPPER) ./xgcc -B./ -B$(build_tooldir)/bin/ -isyste # This is used instead of ALL_CFLAGS when compiling with GCC_FOR_TARGET. # It omits XCFLAGS, and specifies -B./. # It also specifies -isystem ./include to find, e.g., stddef.h. -GCC_CFLAGS=$(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(LOOSE_WARN) -Wold-style-definition $($@-warn) -isystem ./include $(TCFLAGS) +GCC_CFLAGS=$(CFLAGS_FOR_TARGET) $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(LOOSE_WARN) -Wold-style-definition $($@-warn) -isystem ./include $(TCFLAGS) # --------------------------------------------------- # Programs which produce files for the target machine @@ -511,12 +511,20 @@ GGC_LIB= LIBGCC = libgcc.a INSTALL_LIBGCC = install-libgcc +# "true" if the target C library headers are unavailable; "false" +# otherwise. +inhibit_libc = @inhibit_libc@ +ifeq ($(inhibit_libc),true) +INHIBIT_LIBC_CFLAGS = -Dinhibit_libc +endif + # Options to use when compiling libgcc2.a. # LIBGCC2_DEBUG_CFLAGS = -g LIBGCC2_CFLAGS = -O2 $(LIBGCC2_INCLUDES) $(GCC_CFLAGS) $(TARGET_LIBGCC2_CFLAGS) \ $(LIBGCC2_DEBUG_CFLAGS) $(GTHREAD_FLAGS) \ - -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED @inhibit_libc@ + -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \ + $(INHIBIT_LIBC_CFLAGS) # Additional options to use when compiling libgcc2.a. # Some targets override this to -isystem include @@ -528,7 +536,8 @@ TARGET_LIBGCC2_CFLAGS = # Options to use when compiling crtbegin/end. CRTSTUFF_CFLAGS = -O2 $(GCC_CFLAGS) $(INCLUDES) $(MULTILIB_CFLAGS) -g0 \ -finhibit-size-directive -fno-inline-functions -fno-exceptions \ - -fno-zero-initialized-in-bss -fno-unit-at-a-time + -fno-zero-initialized-in-bss -fno-unit-at-a-time \ + $(INHIBIT_LIBC_CFLAGS) # Additional sources to handle exceptions; overridden by targets as needed. LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde.c \ @@ -1393,33 +1402,33 @@ stmp-multilib: $(LIBGCC_DEPS) $(T)crtbegin.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ - @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_BEGIN \ + -c $(srcdir)/crtstuff.c -DCRT_BEGIN \ -o $(T)crtbegin$(objext) $(T)crtend.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ - @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_END \ + -c $(srcdir)/crtstuff.c -DCRT_END \ -o $(T)crtend$(objext) # These are versions of crtbegin and crtend for shared libraries. $(T)crtbeginS.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS_S) \ - @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O \ + -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFS_O \ -o $(T)crtbeginS$(objext) $(T)crtendS.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS_S) \ - @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O \ + -c $(srcdir)/crtstuff.c -DCRT_END -DCRTSTUFFS_O \ -o $(T)crtendS$(objext) # This is a version of crtbegin for -static links. $(T)crtbeginT.o: crtstuff.c $(GCC_PASSES) $(TCONFIG_H) auto-host.h \ gbl-ctors.h stmp-int-hdrs tsystem.h coretypes.h $(TM_H) $(GCC_FOR_TARGET) $(CRTSTUFF_CFLAGS) $(CRTSTUFF_T_CFLAGS) \ - @inhibit_libc@ -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O \ + -c $(srcdir)/crtstuff.c -DCRT_BEGIN -DCRTSTUFFT_O \ -o $(T)crtbeginT$(objext) # Compile the start modules crt0.o and mcrt0.o that are linked with @@ -3137,7 +3146,7 @@ s-macro_list : $(GCC_PASSES) stmp-fixinc: gsyslimits.h macro_list \ $(build_objdir)/fixincludes/fixincl \ $(build_objdir)/fixincludes/fixinc.sh - @if test ! -d ${SYSTEM_HEADER_DIR}; then \ + @if ! $(inhibit_libc) && test ! -d ${SYSTEM_HEADER_DIR}; then \ echo The directory that should contain system headers does not exist: >&2 ; \ echo " ${SYSTEM_HEADER_DIR}" >&2 ; \ if test "x${SYSTEM_HEADER_DIR}" = "x${gcc_tooldir}/sys-include"; \ diff --git a/gcc/configure b/gcc/configure index cb79298..59e0b25 100755 --- a/gcc/configure +++ b/gcc/configure @@ -922,6 +922,8 @@ Optional Packages: --with-as arrange to use the specified as (full pathname) --with-stabs arrange to use stabs instead of host debug format --with-dwarf2 force the default debug format to be DWARF 2 + --with-build-sysroot=sysroot + use sysroot as the system root during the build --with-sysroot=DIR Search for usr/lib, usr/include, et al, within DIR. --with-gnu-ld assume the C compiler uses GNU ld default=no --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib @@ -6934,6 +6936,13 @@ fi; +# Check whether --with-build-sysroot or --without-build-sysroot was given. +if test "${with_build_sysroot+set}" = set; then + withval="$with_build_sysroot" + +fi; + + # Check whether --with-sysroot or --without-sysroot was given. if test "${with_sysroot+set}" = set; then withval="$with_sysroot" @@ -6945,6 +6954,11 @@ if test "${with_sysroot+set}" = set; then TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"' CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR)' + if test "x$with_build_sysroot" != x; then + build_system_header_dir=$with_build_sysroot'$(NATIVE_SYSTEM_HEADER_DIR)' + else + build_system_header_dir='$(CROSS_SYSTEM_HEADER_DIR)' + fi if test "x$exec_prefix" = xNONE; then if test "x$prefix" = xNONE; then @@ -7464,7 +7478,7 @@ if test "${gcc_cv_prog_makeinfo_modern+set}" = set; then else ac_prog_version=`$MAKEINFO --version 2>&1 | sed -n 's/^.*GNU texinfo.* \([0-9][0-9.]*\).*$/\1/p'` - echo "configure:7467: version of makeinfo is $ac_prog_version" >&5 + echo "configure:7481: version of makeinfo is $ac_prog_version" >&5 case $ac_prog_version in '') gcc_cv_prog_makeinfo_modern=no;; 4.[2-9]*) @@ -12737,7 +12751,7 @@ if test x$host != x$target then CROSS="-DCROSS_COMPILE" ALL=all.cross - SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)' + SYSTEM_HEADER_DIR=$build_system_header_dir case "$host","$target" in # Darwin crosses can use the host system's libraries and headers, # because of the fat library support. Of course, it must be the @@ -12771,11 +12785,11 @@ fi # then define inhibit_libc in LIBGCC2_CFLAGS. # This prevents libgcc2 from containing any code which requires libc # support. -inhibit_libc= +inhibit_libc=false if { { test x$host != x$target && test "x$with_sysroot" = x ; } || test x$with_newlib = xyes ; } && { test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then - inhibit_libc=-Dinhibit_libc + inhibit_libc=true fi @@ -13059,7 +13073,7 @@ fi test -n "$gcc_cv_as" && break done -test -n "$gcc_cv_as" || gcc_cv_as="$gcc_cv_tool_prefix/bin/$default_tool_name$build_exeext" +test -n "$gcc_cv_as" || gcc_cv_as="$gcc_cv_tool_prefix/$default_tool_name$build_exeext" fi test "$silent" != yes && exec 6>&1 @@ -13237,7 +13251,7 @@ fi test -n "$gcc_cv_ld" && break done -test -n "$gcc_cv_ld" || gcc_cv_ld="$gcc_cv_tool_prefix/bin/$default_tool_name$build_exeext" +test -n "$gcc_cv_ld" || gcc_cv_ld="$gcc_cv_tool_prefix/$default_tool_name$build_exeext" fi test "$silent" != yes && exec 6>&1 @@ -13381,7 +13395,7 @@ fi test -n "$gcc_cv_nm" && break done -test -n "$gcc_cv_nm" || gcc_cv_nm="$gcc_cv_tool_prefix/bin/$default_tool_name$build_exeext" +test -n "$gcc_cv_nm" || gcc_cv_nm="$gcc_cv_tool_prefix/$default_tool_name$build_exeext" fi test "$silent" != yes && exec 6>&1 diff --git a/gcc/configure.ac b/gcc/configure.ac index 9cc51d5..d9f2167 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -681,6 +681,10 @@ AC_ARG_ENABLE(shared, ], [enable_shared=yes]) AC_SUBST(enable_shared) +AC_ARG_WITH(build-sysroot, + [ --with-build-sysroot=sysroot + use sysroot as the system root during the build]) + AC_ARG_WITH(sysroot, [ --with-sysroot[=DIR] Search for usr/lib, usr/include, et al, within DIR.], [ @@ -691,7 +695,12 @@ AC_ARG_WITH(sysroot, TARGET_SYSTEM_ROOT_DEFINE='-DTARGET_SYSTEM_ROOT=\"$(TARGET_SYSTEM_ROOT)\"' CROSS_SYSTEM_HEADER_DIR='$(TARGET_SYSTEM_ROOT)$(NATIVE_SYSTEM_HEADER_DIR)' - + if test "x$with_build_sysroot" != x; then + build_system_header_dir=$with_build_sysroot'$(NATIVE_SYSTEM_HEADER_DIR)' + else + build_system_header_dir='$(CROSS_SYSTEM_HEADER_DIR)' + fi + if test "x$exec_prefix" = xNONE; then if test "x$prefix" = xNONE; then test_prefix=/usr/local @@ -1643,7 +1652,7 @@ if test x$host != x$target then CROSS="-DCROSS_COMPILE" ALL=all.cross - SYSTEM_HEADER_DIR='$(CROSS_SYSTEM_HEADER_DIR)' + SYSTEM_HEADER_DIR=$build_system_header_dir case "$host","$target" in # Darwin crosses can use the host system's libraries and headers, # because of the fat library support. Of course, it must be the @@ -1677,11 +1686,11 @@ fi # then define inhibit_libc in LIBGCC2_CFLAGS. # This prevents libgcc2 from containing any code which requires libc # support. -inhibit_libc= +inhibit_libc=false if { { test x$host != x$target && test "x$with_sysroot" = x ; } || test x$with_newlib = xyes ; } && { test "x$with_headers" = x || test "x$with_headers" = xno ; } ; then - inhibit_libc=-Dinhibit_libc + inhibit_libc=true fi AC_SUBST(inhibit_libc) diff --git a/gcc/doc/cppopts.texi b/gcc/doc/cppopts.texi index 80bbe50..2790e8c 100644 --- a/gcc/doc/cppopts.texi +++ b/gcc/doc/cppopts.texi @@ -478,6 +478,11 @@ Append @var{dir} to the prefix specified previously with path. @option{-iwithprefixbefore} puts it in the same place @option{-I} would; @option{-iwithprefix} puts it where @option{-idirafter} would. +@item -isysroot @var{dir} +@opindex isysroot +This option is like the @option{--sysroot} option, but applies only to +header files. See the @option{--sysroot} option for more information. + @item -isystem @var{dir} @opindex isystem Search @var{dir} for header files, after all directories specified by diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index ac046c7..2baf003 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -1228,6 +1228,16 @@ in case @option{--with-sysroot} is not given an argument, is subdirectory of @option{$@{exec_prefix@}}, then it will be found relative to the GCC binaries if the installation tree is moved. +@item --with-build-sysroot +@itemx --with-build-sysroot=@var{dir} +Tells GCC to consider @var{dir} as the system root (see +@option{--with-sysroot}) while building the compiler itself, instead of +the directory specified with @option{--with-sysroot}. This option is +only useful when you are already using @option{--with-sysroot}. You +can use @option{--with-build-sysroot} when you are configure with +@option{--prefix} set to a directory that is different from the one in +which you are installing GCC and your target libraries. + @item --with-headers @itemx --with-headers=@var{dir} Deprecated in favor of @option{--with-sysroot}. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 988f13b..f245055 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -349,6 +349,7 @@ Objective-C and Objective-C++ Dialects}. -include @var{file} -imacros @var{file} @gol -iprefix @var{file} -iwithprefix @var{dir} @gol -iwithprefixbefore @var{dir} -isystem @var{dir} @gol +-isysroot @var{dir} @gol -M -MM -MF -MG -MP -MQ -MT -nostdinc @gol -P -fworking-directory -remap @gol -trigraphs -undef -U@var{macro} -Wp,@var{option} @gol @@ -368,7 +369,8 @@ Objective-C and Objective-C++ Dialects}. @item Directory Options @xref{Directory Options,,Options for Directory Search}. -@gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir} -specs=@var{file} -I-} +@gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -L@var{dir} +-specs=@var{file} -I- --sysroot=@var{dir}} @item Target Options @c I wrote this xref this way to avoid overfull hbox. -- rms @@ -6372,6 +6374,22 @@ program uses when determining what switches to pass to @file{cc1}, @option{-specs=@var{file}} can be specified on the command line, and they are processed in order, from left to right. +@item --sysroot=@var{dir} +@opindex sysroot +Use @var{dir} as the logical root directory for headers and libraries. +For example, if the compiler would normally search for headers in +@file{/usr/include} and libraries in @file{/usr/lib}, it will instead +search @file{@var{dir}/usr/include} and @file{@var{dir}/usr/lib}. + +If you use both this option and the @option{-isysroot} option, then +the @option{--sysroot} option will apply to libraries, but the +@option{-isysroot} option will apply to header files. + +The GNU linker (beginning with version 2.16) has the necessary support +for this option. If your linker does not support this option, the +header file aspect of @option{--sysroot} will still work, but the +library aspect will not. + @item -I- @opindex I- This option has been deprecated. Please use @option{-iquote} instead for diff --git a/gcc/gcc.c b/gcc/gcc.c index a701d2c..c62dbbb 100644 --- a/gcc/gcc.c +++ b/gcc/gcc.c @@ -1120,6 +1120,7 @@ static const struct option_map option_map[] = {"--static", "-static", 0}, {"--std", "-std=", "aj"}, {"--symbolic", "-symbolic", 0}, + {"--sysroot", "--sysroot=", "aj"}, {"--time", "-time", 0}, {"--trace-includes", "-H", 0}, {"--traditional", "-traditional", 0}, @@ -3064,6 +3065,9 @@ display_help (void) fputs (_(" -time Time the execution of each subprocess\n"), stdout); fputs (_(" -specs= Override built-in specs with the contents of \n"), stdout); fputs (_(" -std= Assume that the input sources are for \n"), stdout); + fputs (_("\ + --sysroot= Use as the root directory for headers\n\ + for headers and libraries\n"), stdout); fputs (_(" -B Add to the compiler's search paths\n"), stdout); fputs (_(" -b Run gcc for target , if installed\n"), stdout); fputs (_(" -V Run gcc version number , if installed\n"), stdout); @@ -3926,6 +3930,11 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n" ; else if (! strcmp (argv[i], "-fhelp")) ; + else if (! strncmp (argv[i], "--sysroot=", strlen ("--sysroot="))) + { + target_system_root = argv[i] + strlen ("--sysroot="); + target_system_root_changed = 1; + } else if (argv[i][0] == '+' && argv[i][1] == 'e') { /* Compensate for the +e options to the C++ front-end; -- cgit v1.1