From 7df389598b25279db6f58baf11c18eab69ecb5a1 Mon Sep 17 00:00:00 2001 From: Slava Barinov Date: Fri, 3 Mar 2017 14:05:51 +0300 Subject: Generalize search paths to support toolchain detection The script detects right paths to GCC, LLVM and Clang libraries and headers without any hard-coded paths and platform dependencies. Change-Id: I915d65995a74d1e966f10ebc6a79de6f6cf48098 Signed-off-by: Slava Barinov --- packaging/corefx.spec | 81 ++++++++++++++++++++++----------------------------- 1 file changed, 35 insertions(+), 46 deletions(-) diff --git a/packaging/corefx.spec b/packaging/corefx.spec index b469229cac..67dcdc1d5d 100644 --- a/packaging/corefx.spec +++ b/packaging/corefx.spec @@ -140,82 +140,71 @@ tar xf %{SOURCE1000} %ifarch armv7l %setup -T -D -a 1002 %setup -T -D -a 1003 +# Detect interpreter name from cross-gcc +LD_INTERPRETER=$(patchelf --print-interpreter /emul/usr/bin/gcc) +LD_RPATH=$(patchelf --print-rpath /emul/usr/bin/gcc) + for file in $( find ./Tools -name "dotnet" ) do - patchelf --set-interpreter /emul/lib64/ld-linux-x86-64.so.2 $file - patchelf --set-rpath /emul/usr/lib64/:%{_builddir}/%{name}-%{version}/libicu/ $file + patchelf --set-interpreter ${LD_INTERPRETER} ${file} + patchelf --set-rpath ${LD_RPATH}:%{_builddir}/%{name}-%{version}/libicu/ ${file} done for file in $( find ./Tools ./libicu -iname "*.so" -or -iname "*.so.*" ) do - patchelf --set-rpath /emul/usr/lib64/:%{_builddir}/%{name}-%{version}/libicu/ $file + patchelf --set-rpath ${LD_RPATH}:%{_builddir}/%{name}-%{version}/libicu/ ${file} done %endif %endif %build +# Detect paths to toolchain headers in universal way +export GCC_INSTALL_DIR=$(gcc -print-search-dirs | sed -ne '/install: /s/install: //p') +export LLVM_LIBDIR=$(llvm-config --libdir) +export LLVM_INCLUDEDIR=$(llvm-config --includedir) +export GPP_INCLUDE_PATHS=$(cpp -xc++ -v < /dev/null 2>&1 | \ + awk '/search starts here:/{flag=1;next}/End of search list/{flag=0}flag' | \ + sed -e "s/^ //" | tr '\n' ':' | sed -e 's/.$//') +export CLANG_INCLUDE_PATHS=$(clang++ -E -xc++ - -v < /dev/null 2>&1 | \ + awk '/search starts here:/{flag=1;next}/End of search list/{flag=0}flag' | \ + sed -e "s/^ //" | tr '\n' ':' | sed -e 's/.$//') +export CLANG_HEADERS=$(clang++ -print-search-dirs 2>&1 | sed -ne '/libraries: /s/libraries: =//p' | sed -ne 's|:.*|/include|p') + # NOTHING -%ifarch x86_64 -# Even though build architectur is x86_64, it will be running on arm board. -# So we need to pass the arch argument as arm. -%define _barch %{?cross:%{cross}}%{!?cross:x64} %if 0%{skipnative} %else -export LD_LIBRARY_PATH=/usr/lib64/:/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/${LD_LIBRARY_PATH} -export LIBRARY_PATH=/usr/lib64/:/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/:${LIBRARY_PATH} -export CFLAGS="$CFLAGS -B/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/" -export CPPFLAGS="$CPPFLAGS -B/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/" -export CXXFLAGS="$CXXFLAGS -B/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/" -export LDFLAGS="$LDFLAGS -L/usr/lib64/ -L/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/ -I/usr/include/ -B/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/ " -export CPLUS_INCLUDE_PATH=/usr/local/include/llvm/:/usr/local/include/llvm-c/:/usr/local/lib/clang/3.8.1/include/:/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/include/:/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/include/c++/:/usr/lib64/gcc/x86_64-tizen-linux-gnu/4.9.2/include/c++/x86_64-tizen-linux-gnu/:${CPLUS_INCLUDE_PATH} -export C_INCLUDE_PATH=/usr/local/include/llvm-c/:/usr/include/:${C_INCLUDE_PATH} +export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${LLVM_LIBDIR}:${GCC_INSTALL_DIR} +export LIBRARY_PATH=$LIBRARY_PATH:${LLVM_LIBDIR}:${GCC_INSTALL_DIR} +export CFLAGS=" -B${LLVM_LIBDIR} -B${GCC_INSTALL_DIR} -Wno-deprecated-declarations " +export CPPFLAGS=" -B${LLVM_LIBDIR} -B${GCC_INSTALL_DIR} -Wno-deprecated-declarations " +export CXXFLAGS=" -B${LLVM_LIBDIR} -B${GCC_INSTALL_DIR} -Wno-deprecated-declarations " +export LDFLAGS=" -B${LLVM_LIBDIR} -B${GCC_INSTALL_DIR} -Wno-deprecated-declarations " +export CPLUS_INCLUDE_PATH="${GPP_INCLUDE_PATHS}:${LLVM_INCLUDEDIR}/llvm/:${LLVM_INCLUDEDIR}/llvm-c/:${CLANG_HEADERS}:${GPP_INCLUDE_PATHS}:${CLANG_INCLUDE_PATHS}" +export C_INCLUDE_PATH="${LLVM_INCLUDEDIR}/llvm-c/:%{_includedir}" %endif +%ifarch x86_64 +# Even though build architectur is x86_64, it will be running on arm board. +# So we need to pass the arch argument as arm. +%define _barch %{?cross:%{cross}}%{!?cross:x64} + %else %ifarch aarch64 %define _barch arm64 -%if 0%{skipnative} -%else -# BEWARE: NOT EVER TESTED. -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64/gcc/aarch64-tizen-linux/4.9 -export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib64/gcc/aarch64-tizen-linux-gnueabi/4.9 -export CFLAGS="-B/usr/lib64/llvm/ -B/usr/lib64/gcc/aarch64-tizen-linux-gnueabi/4.9/" -export CPPFLAGS="-B/usr/lib64/llvm/ -B/usr/lib64/gcc/aarch64-tizen-linux-gnueabi/4.9/" -export CXXFLAGS="-B/usr/lib64/llvm/ -B/usr/lib64/gcc/aarch64-tizen-linux-gnueabi/4.9/" -export CPLUS_INCLUDE_PATH="/usr/include/llvm/:/usr/include/llvm-c/:/usr/include/c++/4.9/:/usr/include/c++/4.9/backward:/usr/include/c++/4.9/aarch64-tizen-linux-gnueabi/:/usr/local/include:/usr/lib/clang/3.6.0/include/:/usr/include/" -export C_INCLUDE_PATH="/usr/include/llvm-c/:/usr/include/" -%endif - %else %ifarch i586 %define _barch x86 -%if 0%{skipnative} -%else -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/gcc/i586-tizen-linux/4.9 -export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib/gcc/i586-tizen-linux/4.9 -export CFLAGS="-B/usr/lib/llvm/ -B/usr/lib/gcc/i586-tizen-linux/4.9/" -export CPPFLAGS="-B/usr/lib/llvm/ -B/usr/lib/gcc/i586-tizen-linux/4.9/" -export CXXFLAGS="-B/usr/lib/llvm/ -B/usr/lib/gcc/i586-tizen-linux/4.9/" -export CPLUS_INCLUDE_PATH="/usr/include/llvm/:/usr/include/llvm-c/:/usr/include/c++/4.9/:/usr/include/c++/4.9/backward:/usr/include/c++/4.9/i586-tizen-linux/:/usr/local/include:/usr/lib/clang/3.6.0/include/:/usr/include/" -export C_INCLUDE_PATH="/usr/include/llvm-c/:/usr/include/" -%endif - %else %ifarch armv7l %define _barch armel %if 0%{skipnative} %else -export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2 -export LIBRARY_PATH=$LIBRARY_PATH:/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2 -export CFLAGS="-U__GNUC_MINOR__ -D__GNUC_MINOR__=3 -B/usr/local/lib/ -L/lib/ -L/usr/lib/ -L/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -B/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -O2 --param=ssp-buffer-size=32 -fdiagnostics-color=never -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -Wp,-D__SOFTFP__ -Wno-error=inline-asm -integrated-as -Wno-ignored-attributes -Wno-switch-enum -Wno-switch -Wno-error=switch -Wno-error=switch-enum -w" -export CPPFLAGS="-U__GNUC_MINOR__ -D__GNUC_MINOR__=3 -B/usr/local/lib/ -L/lib/ -L/usr/lib/ -L/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -B/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -O2 --param=ssp-buffer-size=32 -fdiagnostics-color=never -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -Wp,-D__SOFTFP__ -Wno-error=inline-asm -integrated-as -Wno-ignored-attributes -Wno-switch-enum -Wno-switch -Wno-error=switch -Wno-error=switch-enum -w" -export CXXFLAGS="-U__GNUC_MINOR__ -D__GNUC_MINOR__=3 -B/usr/local/lib/ -L/lib/ -L/usr/lib/ -L/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -B/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -O2 --param=ssp-buffer-size=32 -fdiagnostics-color=never -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -Wp,-D__SOFTFP__ -Wno-error=inline-asm -integrated-as -Wno-ignored-attributes -Wno-switch-enum -Wno-switch -Wno-error=switch -Wno-error=switch-enum -w" -export CPLUS_INCLUDE_PATH="/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/:/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/armv7l-tizen-linux-gnueabi/:/usr/local/include/llvm/:/usr/local/include/llvm-c/:/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/:/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/backward:/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/include/c++/armv7l-tizen-linux-gnueabi/:/usr/local/include:/usr/include/" -export C_INCLUDE_PATH="/usr/local/include/llvm-c/:/usr/include/" -export LDFLAGS="-U__GNUC_MINOR__ -D__GNUC_MINOR__=3 -B/usr/local/lib/ -L/lib/ -L/usr/lib/ -L/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -B/usr/lib/gcc/armv7l-tizen-linux-gnueabi/4.9.2/ -O2 --param=ssp-buffer-size=32 -fdiagnostics-color=never -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -Wp,-D__SOFTFP__ -Wno-error=inline-asm -integrated-as -Wno-ignored-attributes -Wno-switch-enum -Wno-switch -Wno-error=switch -Wno-error=switch-enum -w" +export CFLAGS="${CFLAGS} -U__GNUC_MINOR__ -D__GNUC_MINOR__=3 -O2 --param=ssp-buffer-size=32 -fdiagnostics-color=never -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -Wp,-D__SOFTFP__ -Wno-error=inline-asm -integrated-as -Wno-ignored-attributes -Wno-switch-enum -Wno-switch -Wno-error=switch -Wno-error=switch-enum -w" +export CPPFLAGS="${CPPFLAGS} -U__GNUC_MINOR__ -D__GNUC_MINOR__=3 -O2 --param=ssp-buffer-size=32 -fdiagnostics-color=never -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -Wp,-D__SOFTFP__ -Wno-error=inline-asm -integrated-as -Wno-ignored-attributes -Wno-switch-enum -Wno-switch -Wno-error=switch -Wno-error=switch-enum -w" +export CXXFLAGS="${CXXFLAGS} -U__GNUC_MINOR__ -D__GNUC_MINOR__=3 -O2 --param=ssp-buffer-size=32 -fdiagnostics-color=never -march=armv7-a -mtune=cortex-a8 -mlittle-endian -mfpu=neon -mfloat-abi=softfp -Wp,-D__SOFTFP__ -Wno-error=inline-asm -integrated-as -Wno-ignored-attributes -Wno-switch-enum -Wno-switch -Wno-error=switch -Wno-error=switch-enum -w" %endif %else -- cgit v1.2.3