Hi, Sorry for having misspelled the mailing list address in my previous emails.
Here is the amended patch with the comments from Joerg and Rafael. The patch adds a configure flag --with-default-sysroot that will set the default value of the clang flag --sysroot. The configure time flag name has been intentionally renamed from --with-sysroot in order to avoid confusion with the semantics of this flag in the gcc configure. Please review and let me know how I can improve this patch. Joerg, concerning your remark: > My question still stands. Do you want to emulate the (IMO insane) GCC > configure option or just provide a default value for --sysroot. If the The patch intends to provide a default value to --sysroot: I do not want to emulate the semantics of GCC's configure flag. > latter, the option should be named differently to avoid confusion. > I don't think this patch really implements this behavior though. Please let me know if this current patch addresses your concerns. Thanks, Sebastian On Mon, Mar 5, 2012 at 3:46 PM, Sebastian Pop <[email protected]> wrote: > Hi, > > Ping: could you please review the attached patches? > These are adding a configure time flag for a flag accepted by clang at > compile time. > When the configure time flag is set, it will serve as the default value. > > Thanks, > Sebastian > > On Thu, Feb 9, 2012 at 2:28 PM, Sebastian Pop <[email protected]> wrote: >> On Thu, Feb 9, 2012 at 12:42 PM, Sebastian Pop <[email protected]> wrote: >>> As there is no way to specify a --sysroot= at configure time, what >>> about adding the configure flag --with-sysroot and initialize sysroot >>> from there if clang has not been passed a --sysroot= flag? >> >> This is implemented in the attached patches. >> -- Qualcomm Innovation Center, Inc is a member of Code Aurora Forum
From fe3577c513748ca4461961e1a8a1ec0e623ec4ee Mon Sep 17 00:00:00 2001 From: Sebastian Pop <[email protected]> Date: Thu, 9 Feb 2012 13:02:01 -0600 Subject: [PATCH] add configure flag --with-default-sysroot --- autoconf/configure.ac | 7 +++++++ configure | 17 ++++++++++++++++- include/llvm/Config/config.h.cmake | 3 +++ include/llvm/Config/config.h.in | 3 +++ 4 files changed, 29 insertions(+), 1 deletions(-) diff --git a/autoconf/configure.ac b/autoconf/configure.ac index e18725d..189676f 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -845,6 +845,13 @@ AC_ARG_WITH(gcc-toolchain, AC_DEFINE_UNQUOTED(GCC_INSTALL_PREFIX,"$withval", [Directory where gcc is installed.]) +AC_ARG_WITH(sysroot, + AS_HELP_STRING([--with-default-sysroot], + [Add --sysroot=<path> to all compiler invocations.]),, + withval="") +AC_DEFINE_UNQUOTED(DEFAULT_SYSROOT,"$withval", + [Default <path> to all compiler invocations for --sysroot=<path>.]) + dnl Allow linking of LLVM with GPLv3 binutils code. AC_ARG_WITH(binutils-include, AS_HELP_STRING([--with-binutils-include], diff --git a/configure b/configure index a6ed7a1..f7f1223 100755 --- a/configure +++ b/configure @@ -1444,6 +1444,7 @@ Optional Packages: --with-c-include-dirs Colon separated list of directories clang will search for headers --with-gcc-toolchain Directory where gcc is installed. + --with-default-sysroot Add --sysroot=<path> to all compiler invocations. --with-binutils-include Specify path to binutils/include/ containing plugin-api.h file for gold plugin. --with-bug-report-url Specify the URL where bug reports should be @@ -5594,6 +5595,20 @@ _ACEOF +# Check whether --with-sysroot was given. +if test "${with_sysroot+set}" = set; then + withval=$with_sysroot; +else + withval="" +fi + + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_SYSROOT "$withval" +_ACEOF + + + # Check whether --with-binutils-include was given. if test "${with_binutils_include+set}" = set; then withval=$with_binutils_include; @@ -10464,7 +10479,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<EOF -#line 10467 "configure" +#line 10482 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index c475014..e8a3e2b 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -17,6 +17,9 @@ /* Directories clang will search for headers */ #define C_INCLUDE_DIRS "${C_INCLUDE_DIRS}" +/* Default <path> to all compiler invocations for --sysroot=<path>. */ +#define DEFAULT_SYSROOT "${DEFAULT_SYSROOT}" + /* Define if CBE is enabled for printf %a output */ #cmakedefine ENABLE_CBE_PRINTF_A ${ENABLE_CBE_PRINTF_A} diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 1a996a2..62376b1 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -12,6 +12,9 @@ /* Directories clang will search for headers */ #undef C_INCLUDE_DIRS +/* Default <path> to all compiler invocations for --sysroot=<path>. */ +#undef DEFAULT_SYSROOT + /* Define if CBE is enabled for printf %a output */ #undef ENABLE_CBE_PRINTF_A -- 1.7.5.4
From 908106a9600a34e3d2639d92ce9c8bcd23d5b0db Mon Sep 17 00:00:00 2001 From: Sebastian Pop <[email protected]> Date: Thu, 9 Feb 2012 13:06:08 -0600 Subject: [PATCH] use DEFAULT_SYSROOT --- include/clang/Config/config.h.cmake | 9 ++++++--- include/clang/Config/config.h.in | 9 ++++++--- lib/Driver/Driver.cpp | 10 +++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/include/clang/Config/config.h.cmake b/include/clang/Config/config.h.cmake index bd5dc31..c18c4cc 100644 --- a/include/clang/Config/config.h.cmake +++ b/include/clang/Config/config.h.cmake @@ -4,8 +4,11 @@ /* Relative directory for resource files */ #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}" -/* Directory where gcc is installed. */ -#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}" - /* Directories clang will search for headers */ #define C_INCLUDE_DIRS "${C_INCLUDE_DIRS}" + +/* Default <path> to all compiler invocations for --sysroot=<path>. */ +#define DEFAULT_SYSROOT "${DEFAULT_SYSROOT}" + +/* Directory where gcc is installed. */ +#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}" diff --git a/include/clang/Config/config.h.in b/include/clang/Config/config.h.in index 3f5d503..24ed6bd 100644 --- a/include/clang/Config/config.h.in +++ b/include/clang/Config/config.h.in @@ -9,10 +9,13 @@ /* Relative directory for resource files */ #undef CLANG_RESOURCE_DIR -/* Directory where gcc is installed. */ -#undef GCC_INSTALL_PREFIX - /* Directories clang will search for headers */ #undef C_INCLUDE_DIRS +/* Default <path> to all compiler invocations for --sysroot=<path>. */ +#undef DEFAULT_SYSROOT + +/* Directory where gcc is installed. */ +#undef GCC_INSTALL_PREFIX + #endif diff --git a/lib/Driver/Driver.cpp b/lib/Driver/Driver.cpp index e71f5a6..2790e18 100644 --- a/lib/Driver/Driver.cpp +++ b/lib/Driver/Driver.cpp @@ -322,8 +322,16 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) { A->claim(); PrefixDirs.push_back(A->getValue(*Args, 0)); } - if (const Arg *A = Args->getLastArg(options::OPT__sysroot_EQ)) + if (const Arg *A = Args->getLastArg(options::OPT__sysroot_EQ)) { SysRoot = A->getValue(*Args); + } else { + StringRef Prefix(DEFAULT_SYSROOT); + if (Prefix != "") { + if (Prefix.back() == '/') + llvm::sys::path::remove_filename(Prefix); // remove the / + SysRoot = Prefix.str(); + } + } if (Args->hasArg(options::OPT_nostdlib)) UseStdLib = false; -- 1.7.5.4
_______________________________________________ cfe-commits mailing list [email protected] http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
