diff options
author | Jan Vorlicek <janvorli@microsoft.com> | 2019-03-11 14:59:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-11 14:59:27 +0100 |
commit | 123422de218d6ca5c36cbb7f34ece95dcae333da (patch) | |
tree | 777ca1b5fadc3d18c4c1f6332cc3672b93cf448a /src/pal | |
parent | 20ec8fa5448655309490106cf7ac72bf60b3485f (diff) | |
parent | 107b9424d7dd56c1902b09bb1c67533215190ea8 (diff) | |
download | coreclr-123422de218d6ca5c36cbb7f34ece95dcae333da.tar.gz coreclr-123422de218d6ca5c36cbb7f34ece95dcae333da.tar.bz2 coreclr-123422de218d6ca5c36cbb7f34ece95dcae333da.zip |
Merge pull request #23111 from am11/gcc-configuration
Improve gcc configuration
Diffstat (limited to 'src/pal')
-rw-r--r-- | src/pal/src/configure.cmake | 16 | ||||
-rwxr-xr-x | src/pal/tools/gen-buildsys-gcc.sh | 77 |
2 files changed, 43 insertions, 50 deletions
diff --git a/src/pal/src/configure.cmake b/src/pal/src/configure.cmake index c8b6f3bd6e..a4d550e03b 100644 --- a/src/pal/src/configure.cmake +++ b/src/pal/src/configure.cmake @@ -42,13 +42,15 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) check_include_files("libintl.h" HAVE_LIBINTL_H) endif() -if(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD) - set(CMAKE_REQUIRED_FLAGS "-ldl") -endif() -check_include_files(lttng/tracepoint.h HAVE_LTTNG_TRACEPOINT_H) -if(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD) - unset(CMAKE_REQUIRED_FLAGS) -endif() +set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS}) + +check_cxx_source_compiles(" +#include <lttng/tracepoint.h> +int main(int argc, char **argv) { + return 0; +}" HAVE_LTTNG_TRACEPOINT_H) + +set(CMAKE_REQUIRED_LIBRARIES) check_include_files(sys/sysctl.h HAVE_SYS_SYSCTL_H) check_include_files(gnu/lib-names.h HAVE_GNU_LIBNAMES_H) diff --git a/src/pal/tools/gen-buildsys-gcc.sh b/src/pal/tools/gen-buildsys-gcc.sh index cc141baae9..0d66368048 100755 --- a/src/pal/tools/gen-buildsys-gcc.sh +++ b/src/pal/tools/gen-buildsys-gcc.sh @@ -9,8 +9,8 @@ then echo "gen-buildsys-gcc.sh <path to top level CMakeLists.txt> <GccMajorVersion> <GccMinorVersion> <Architecture> [build flavor] [coverage] [ninja] [cmakeargs]" echo "Specify the path to the top level CMake file - <ProjectK>/src/NDP" echo "Specify the Gcc version to use, split into major and minor version" - echo "Specify the target architecture." - echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." + echo "Specify the target architecture." + echo "Optionally specify the build configuration (flavor.) Defaults to DEBUG." echo "Optionally specify 'coverage' to enable code coverage build." echo "Target ninja instead of make. ninja must be on the PATH." echo "Pass additional arguments to CMake call." @@ -22,7 +22,7 @@ gcc_prefix="" if [ "$CROSSCOMPILE" = "1" ]; then # Locate gcc - if [ ! -z "$TOOLCHAIN" ]; then + if [ -n "$TOOLCHAIN" ]; then gcc_prefix="$TOOLCHAIN-" fi fi @@ -37,21 +37,28 @@ elif command -v "${gcc_prefix}gcc$2$3" > /dev/null elif command -v "${gcc_prefix}gcc-$2$3" > /dev/null then desired_gcc_version="-$2$3" -elif command -v ${gcc_prefix}gcc > /dev/null +elif command -v "${gcc_prefix}gcc" > /dev/null then desired_gcc_version= else - echo "Unable to find $gcc_prefixgcc Compiler" + echo "Unable to find ${gcc_prefix}gcc Compiler" exit 1 fi -if [ -z "$CC" ]; then - export CC="$(command -v ${gcc_prefix}gcc$desired_gcc_version)" +if [ -z "$CLR_CC" ]; then + CC="$(command -v "${gcc_prefix}gcc$desired_gcc_version")" +else + CC="$CLR_CC" fi -if [ -z "$CXX" ]; then - export CXX="$(command -v ${gcc_prefix}g++$desired_gcc_version)" + +if [ -z "$CLR_CXX" ]; then + CXX="$(command -v "${gcc_prefix}g++$desired_gcc_version")" +else + CXX="$CLR_CXX" fi +export CC CXX + build_arch="$4" buildtype=DEBUG code_coverage=OFF @@ -60,9 +67,9 @@ __UnprocessedCMakeArgs="" ITER=-1 for i in "$@"; do - ITER=$(($ITER + 1)) + ITER=$((ITER + 1)) if [ $ITER -lt 5 ]; then continue; fi - upperI="$(echo $i | awk '{print toupper($0)}')" + upperI="$(echo "$i" | awk '{print toupper($0)}')" case $upperI in # Possible build types are DEBUG, CHECKED, RELEASE, RELWITHDEBINFO, MINSIZEREL. DEBUG | CHECKED | RELEASE | RELWITHDEBINFO | MINSIZEREL) @@ -80,55 +87,39 @@ for i in "$@"; do esac done -OS=`uname` +OS=$(uname) locate_gcc_exec() { + ENV_KNOB="CLR_$(echo "$1" | tr '[:lower:]' '[:upper:]')" + if env | grep -q "^$ENV_KNOB="; then + eval "echo \"\$$ENV_KNOB\"" + return + fi + if command -v "$gcc_prefix$1$desired_gcc_version" > /dev/null 2>&1 then - echo "$(command -v $gcc_prefix$1$desired_gcc_version)" + command -v "$gcc_prefix$1$desired_gcc_version" elif command -v "$gcc_prefix$1" > /dev/null 2>&1 then - echo "$(command -v $gcc_prefix$1)" + command -v "$gcc_prefix$1" else exit 1 fi } -gcc_ar="$(locate_gcc_exec ar)" -[ $? -eq 0 ] || { echo "Unable to locate gcc-ar"; exit 1; } +if ! gcc_link="$(locate_gcc_exec link)"; then { echo "Unable to locate link"; exit 1; } fi -if [ -z "$CC" ]; then - gcc_link="$(locate_gcc_exec gcc)" - [ $? -eq 0 ] || { echo "Unable to locate gcc-link"; exit 1; } -else - gcc_link="$CC" -fi +if ! gcc_ar="$(locate_gcc_exec ar)"; then { echo "Unable to locate gcc-ar"; exit 1; } fi -if [ -z "$NM" ]; then - gcc_nm="$(locate_gcc_exec nm)" - [ $? -eq 0 ] || { echo "Unable to locate gcc-nm"; exit 1; } -else - gcc_nm="$NM" -fi +if ! gcc_nm="$(locate_gcc_exec nm)"; then { echo "Unable to locate gcc-nm"; exit 1; } fi if [ "$OS" = "Linux" ] || [ "$OS" = "FreeBSD" ] || [ "$OS" = "OpenBSD" ] || [ "$OS" = "NetBSD" ] || [ "$OS" = "SunOS" ]; then - if [ -z "$OBJDUMP" ]; then - gcc_objdump="$(locate_gcc_exec objdump)" - [ $? -eq 0 ] || { echo "Unable to locate gcc-objdump"; exit 1; } - else - gcc_objdump="$OBJDUMP" - fi + if ! gcc_objdump="$(locate_gcc_exec objdump)"; then { echo "Unable to locate gcc-objdump"; exit 1; } fi fi -if [ -z "$OBJCOPY" ]; then - gcc_objcopy="$(locate_gcc_exec objcopy)" - [ $? -eq 0 ] || { echo "Unable to locate gcc-objcopy"; exit 1; } -else - gcc_objcopy="$OBJCOPY" -fi +if ! gcc_objcopy="$(locate_gcc_exec objcopy)"; then { echo "Unable to locate gcc-objcopy"; exit 1; } fi -gcc_ranlib="$(locate_gcc_exec ranlib)" -[ $? -eq 0 ] || { echo "Unable to locate gcc-ranlib"; exit 1; } +if ! gcc_ranlib="$(locate_gcc_exec ranlib)"; then { echo "Unable to locate gcc-ranlib"; exit 1; } fi cmake_extra_defines= if [ -n "$LLDB_LIB_DIR" ]; then @@ -184,5 +175,5 @@ cmake \ "-DCLR_CMAKE_ENABLE_CODE_COVERAGE=$code_coverage" \ "-DCLR_CMAKE_COMPILER=GNU" \ $cmake_extra_defines \ - $__UnprocessedCMakeArgs \ + "$__UnprocessedCMakeArgs" \ "$1" |