SVN commit 1304629 by lunakl: Hack for compiling with clang even on older icecream remotes. Older icecream versions had /usr/bin/{gcc|g++} hardcoded when invoking the compiler from the environment on the remote. In order to build on such remotes, if the environment also contains clang, include a wrapper around /usr/bin/{gcc|g++} that will either invoke real gcc or clang, depending on an argument added by icecream. Not entirely elegant, but it works, and the usual gcc-only case should be unaffected. M +1 -1 Makefile.am M +19 -1 client/icecc-create-env M +10 -1 client/main.cpp M +1 -0 configure.in M +12 -0 services/comm.cpp --- trunk/icecream/Makefile.am #1304628:1304629 @@ -1,5 +1,5 @@ -SUBDIRS = minilzo services daemon client doc suse +SUBDIRS = minilzo services daemon client doc suse compilerwrapper AUTOMAKE_OPTIONS = foreign 1.6 .PHONY: changes --- trunk/icecream/client/icecc-create-env #1304628:1304629 @@ -14,7 +14,7 @@ usage () { echo "usage: $0 " - echo "usage: $0 [|] [|] " + echo "usage: $0 [|] [|] " } is_contained () @@ -112,7 +112,13 @@ echo "'$added_clang' is no executable." exit 1 fi + added_compilerwrapper=$1 + shift + if ! test -x "$added_compilerwrapper" ; then + echo "'$added_compilerwrapper' is no executable." + exit 1 fi +fi if test -z "$gcc" && test -z "$clang"; then usage @@ -122,8 +128,15 @@ tempdir=`mktemp -d /tmp/iceccenvXXXXXX` if test -n "$gcc"; then + if test -z "$clang"; then add_file $added_gcc /usr/bin/gcc add_file $added_gxx /usr/bin/g++ + else + # HACK: The clang case below will add a wrapper in place of gcc, so add the real + # gcc under a different name that the wrapper will call. + add_file $added_gcc /usr/bin/gcc.bin + add_file $added_gxx /usr/bin/g++.bin + fi add_file `$added_gcc -print-prog-name=cc1` /usr/bin/cc1 add_file `$added_gxx -print-prog-name=cc1plus` /usr/bin/cc1plus specfile=`$added_gcc -print-file-name=specs` @@ -144,6 +157,11 @@ if test -n "$clang"; then add_file $added_clang /usr/bin/clang + # HACK: Older icecream remotes have /usr/bin/{gcc|g++} hardcoded and wouldn't + # call /usr/bin/clang at all. So include a wrapper binary that will call gcc or clang + # depending on an extra argument added by icecream. + add_file $added_compilerwrapper /usr/bin/gcc + add_file $added_compilerwrapper /usr/bin/g++ # clang requires /tmp mkdir "$tempdir"/tmp/ chmod 1777 "$tempdir"/tmp/ --- trunk/icecream/client/main.cpp #1304628:1304629 @@ -185,12 +185,21 @@ return 1; } + if ( !clang.empty() && lstat( PLIBDIR "/compilerwrapper", &st ) ) { + log_error() << PLIBDIR "/compilerwrapper does not exist\n"; + return 1; + } + char **argv = new char*[5]; argv[0] = strdup( PLIBDIR "/icecc-create-env" ); argv[1] = strdup( gcc.c_str() ); argv[2] = strdup( gpp.c_str() ); + argv[3] = NULL; + if( !clang.empty()) { argv[3] = strdup( clang.c_str() ); - argv[4] = NULL; + argv[4] = strdup( PLIBDIR "/compilerwrapper" ); + argv[5] = NULL; + } return execv(argv[0], argv); --- trunk/icecream/configure.in #1304628:1304629 @@ -230,6 +230,7 @@ AC_CONFIG_FILES([ services/Makefile ]) AC_CONFIG_FILES([ services/icecc.pc ]) AC_CONFIG_FILES([ suse/Makefile ]) +AC_CONFIG_FILES([ compilerwrapper/Makefile ]) AC_OUTPUT([ suse/icecream.spec ]) if test "$prefix" = NONE; then prefix=$ac_default_prefix --- trunk/icecream/services/comm.cpp #1304628:1304629 @@ -1352,7 +1352,19 @@ Msg::send_to_channel (c); *c << (uint32_t) job->language(); *c << job->jobID(); + if (IS_PROTOCOL_30(c)) *c << job->remoteFlags(); + else + { + if (job->compilerName().find("clang") != string::npos) + { // Hack for compilerwrapper. + std::list flags = job->remoteFlags(); + flags.push_front("clang"); + *c << flags; + } + else + *c << job->remoteFlags(); + } *c << job->restFlags(); *c << job->environmentVersion(); *c << job->targetPlatform();