]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
configure: fix build with arbitrary CC and LD_LIBRARY_PATH
authorEmanuele Torre <torreemanuele6@gmail.com>
Tue, 23 May 2023 09:59:59 +0000 (11:59 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Thu, 25 May 2023 08:36:43 +0000 (10:36 +0200)
Since ./configure and processes that inherit its environment variables
are the only callers of the run-compiler script, we can just save the
current value of the LD_LIBRARY_PATH and CC variables to another pair of
environment variables, and make run-compiler a static script that
simply restores CC and LD_LIBRARY_PATH to the saved value, and before
running the compiler.

This avoids having to inject the values of the variables in the script,
possibly causing problems if they contains spaces, quotes, and other
special characters.

Also add exports in the script just in case LD_LIBRARY_PATH and CC are
not already in the environment.

follow-up from 471dab2

Closes #11182

configure.ac

index 17dd05a94c9a2dbf611c261e9c5e0bf0fee263ea..0f316d0bb87872d72be943f0490ce51a59c2ce72 100644 (file)
@@ -193,9 +193,13 @@ dnl something different but only have that affect the execution of the results
 dnl of the compile, not change the libraries for the compiler itself.
 dnl
 compilersh="run-compiler"
-echo "CC=\"$CC\"" > $compilersh
-echo "LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH\"" >> $compilersh
-echo 'exec $CC $@' >> $compilersh
+export "CURL_SAVED_CC=$CC"
+export "CURL_SAVED_LD_LIBRARY_PATH=$LD_LIBRARY_PATH"
+cat <<\EOF > "$compilersh"
+export "CC=$CURL_SAVED_CC"
+export "LD_LIBRARY_PATH=$CURL_SAVED_LD_LIBRARY_PATH"
+exec $CC "$@"
+EOF
 
 dnl **********************************************************************
 dnl See which TLS backend(s) that are requested. Just do all the