Address @janvorli's feedback
authorAdeel <adeelbm@outlook.com>
Fri, 8 Mar 2019 01:29:22 +0000 (17:29 -0800)
committerAdeel <adeelbm@outlook.com>
Fri, 8 Mar 2019 12:22:08 +0000 (04:22 -0800)
Commit migrated from https://github.com/dotnet/coreclr/commit/6d26a56a77e86edd3d1df4161c8a9ada5b99a35b

src/coreclr/src/pal/src/configure.cmake
src/coreclr/src/pal/tools/gen-buildsys-gcc.sh

index 73c5c1c..1422cd0 100644 (file)
@@ -43,11 +43,17 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL Darwin)
 endif()
 
 if(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
-  set(CMAKE_REQUIRED_FLAGS "-ldl")
+  set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_DL_LIBS})
 endif()
-find_path (HAVE_LTTNG_TRACEPOINT_H NAMES lttng/tracepoint.h)
+
+check_cxx_source_compiles("
+#include <lttng/tracepoint.h>
+int main(int argc, char **argv) {
+  return 0;
+}" HAVE_LTTNG_TRACEPOINT_H)
+
 if(NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
-  unset(CMAKE_REQUIRED_FLAGS)
+  set(CMAKE_REQUIRED_LIBRARIES)
 endif()
 
 check_include_files(sys/sysctl.h HAVE_SYS_SYSCTL_H)
index 7aba64c..5a72549 100755 (executable)
@@ -41,21 +41,22 @@ elif command -v "${gcc_prefix}gcc" > /dev/null
     then
         desired_gcc_version=
 else
-    echo "Unable to find \"${gcc_prefix}\"gcc Compiler"
+    echo "Unable to find ${gcc_prefix}gcc Compiler"
     exit 1
 fi
 
-if [ -z "$DOTNET_CC" ]; then
+if [ -z "$CLR_CC" ]; then
     CC="$(command -v "${gcc_prefix}"gcc"$desired_gcc_version")"
-    export CC
+    gcc_link="$(command -v link)"
 else
-    CC="$DOTNET_CC"
+    CC="$CLR_CC"
+    gcc_link="$CC"
 fi
 
-if [ -z "$DOTNET_CXX" ]; then
+if [ -z "$CLR_CXX" ]; then
     CXX="$(command -v "${gcc_prefix}g++$desired_gcc_version")"
 else
-    CXX="$DOTNET_CXX"
+    CXX="$CLR_CXX"
 fi
 
 export CC CXX
@@ -91,9 +92,9 @@ done
 OS=$(uname)
 
 locate_gcc_exec() {
-  ENV_KNOB="DOTNET_$(echo "$1" | tr '[:lower:]' '[:upper:]')"
-  if [ -n $(eval "\$$ENV_KNOB") ]; then
-    $(eval "\$$ENV_KNOB")
+  ENV_KNOB="CLR_$(echo "$1" | tr '[:lower:]' '[:upper:]')"
+  if env | grep -q "^$ENV_KNOB="; then
+    eval "echo \"\$$ENV_KNOB\""
     return
   fi
 
@@ -110,8 +111,6 @@ locate_gcc_exec() {
 
 if ! gcc_ar="$(locate_gcc_exec ar)"; then { echo "Unable to locate gcc-ar"; exit 1; } fi
 
-if ! gcc_link="$(locate_gcc_exec link)"; then { echo "Unable to locate gcc-link"; exit 1; } 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