summaryrefslogtreecommitdiff
path: root/src/pal/src
diff options
context:
space:
mode:
authorSinan Kaya <41809318+franksinankaya@users.noreply.github.com>2019-02-07 16:39:13 -0500
committerJan Vorlicek <janvorli@microsoft.com>2019-02-07 22:39:13 +0100
commit34d50b056150ba9101ee977dded9cee3c663fab6 (patch)
tree87c392937ae80e2dabf379b3c1a58b229daacf00 /src/pal/src
parent46cbd93c20780bcacd9f39fe18079acf2a9f4178 (diff)
downloadcoreclr-34d50b056150ba9101ee977dded9cee3c663fab6.tar.gz
coreclr-34d50b056150ba9101ee977dded9cee3c663fab6.tar.bz2
coreclr-34d50b056150ba9101ee977dded9cee3c663fab6.zip
More PAL layer cleanup for GNU and add build script support for GCC (#22369)
* Declare throw only when compiling for c++ Prevent the definition from getting defined multiple times and map it to throw() only when compiling c++ code. * Suppress warnings for tests Suppress: -Wno-write-strings -Wno-sign-compare -Wno-narrowing -fpermissive -Wno-int-to-pointer-cast to allow tests to compile * Add gcc option to build.sh script Following clangx.y model add -gccx.y command line arguments with gcc5 and gcc7 being the currnetly supported options. * Allow environment variable to be used for TOOLCHAIN Remove CLANG specific compiler options as well. * Hide non-GNU compiler options * Do not include local directory if cross compiling [ 0%] Building CXX object src/pal/src/eventprovider/tracepointprovider/CMakeFiles/coreclrtraceptprovider.dir/__/lttng/traceptprovdotnetruntime.cpp.o cc1plus: error: include location "/usr/local/include" is unsafe for cross-compilation [-Werror=poison-system-directories] * Suppress unknown pragma warnings src/pal/src/exception/seh-unwind.cpp:37:0: warning: ignoring #pragma clang diagnostic [-Wunknown-pragmas] #pragma clang diagnostic pop Removing these cause compilation error on clang7 and arm as follows: In file included from /bin/obj/Linux.arm.Debug/src/pal/src/libunwind/include/libunwind.h:9: /src/pal/src/libunwind/include/libunwind-arm.h:247:9: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat] typedef struct unw_tdep_save_loc ^ /src/pal/src/libunwind/include/libunwind-arm.h:288:9: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat] typedef struct * plt not useful for GNU and ARM64/ARM src/pal/src/arch/arm64/callsignalhandlerwrapper.S: Assembler messages: src/pal/src/arch/arm64/callsignalhandlerwrapper.S:31: Error: unexpected characters following instruction at operand 1 -- `bl signal_handler_worker@plt' src/pal/src/arch/arm64/callsignalhandlerwrapper.S:32: Error: unexpected characters following instruction at operand 1 -- `bl signal_handler_worker@plt' * Remove double const from argv in PAL_Initialize Seeing compilation error with GNU for C source files as follows: if (PAL_Initialize(argc, argv) != 0) ^ src/pal/tests/palsuite/common/palsuite.h:21:0, from src/pal/tests/palsuite/c_runtime/asinhf/test1/test1.c:18: src/pal/inc/pal.h:374:1: note: expected ‘const char * const*’ but argument is of type ‘char **’ * Suppress format warnings using GNU for libunwind warning: format ‘%li’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=] Debug (4, " aligned frame, offset %li\n", f->cfa_reg_offset); * Fix -fpermissive warnings for GNU * Suppress unused variable warning in libunwind src/pal/src/libunwind/include/libunwind-aarch64.h:201:5: warning: right-hand operand of comma expression has no effect [-Wunused-value] #define unw_tdep_getcontext(uc) (({ \ ~~~~~~~~~ unw_tdep_context_t *unw_ctx = (uc); \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ register uint64_t *unw_base asm ("x0") = (uint64_t*) unw_ctx->uc_mcontext.regs; \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ __asm__ __volatile__ ( \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x0, x1, [%[base], #0]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x2, x3, [%[base], #16]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x4, x5, [%[base], #32]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x6, x7, [%[base], #48]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x8, x9, [%[base], #64]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x10, x11, [%[base], #80]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x12, x13, [%[base], #96]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x14, x13, [%[base], #112]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x16, x17, [%[base], #128]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x18, x19, [%[base], #144]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x20, x21, [%[base], #160]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x22, x23, [%[base], #176]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x24, x25, [%[base], #192]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x26, x27, [%[base], #208]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "stp x28, x29, [%[base], #224]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "str x30, [%[base], #240]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ "mov x1, sp\n" \ ~~~~~~~~~~~~~~~~ "stp x1, x30, [%[base], #248]\n" \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ : [base] "+r" (unw_base) : : "x1", "memory"); \ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ }), 0) * Fix warning: ‘memset’ used with length equal to number of elements warning Fix similar warnings to these by including the element size into total size calculation. src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp: In function ‘int main(int, char**)’: src/pal/tests/palsuite/miscellaneous/SetEnvironmentVariableW/test1/test.cpp:89:31: warning: ‘memset’ used with length equal to number of elements without multiplication by element size [-Wmemset-elt-size] memset(NewValue,0,BUF_SIZE); * Define CLR specific compiler option CLR_CMAKE_COMPILER By the time toolchain.cmake is called, the compiler detection from cmake is not active. We need an intermediate definition to pass to compiler detection.
Diffstat (limited to 'src/pal/src')
-rw-r--r--src/pal/src/CMakeLists.txt4
-rw-r--r--src/pal/src/examples/example1.cpp2
-rw-r--r--src/pal/src/exception/remote-unwind.cpp4
-rw-r--r--src/pal/src/exception/seh-unwind.cpp4
-rw-r--r--src/pal/src/init/pal.cpp2
-rw-r--r--src/pal/src/libunwind/src/CMakeLists.txt21
6 files changed, 29 insertions, 8 deletions
diff --git a/src/pal/src/CMakeLists.txt b/src/pal/src/CMakeLists.txt
index 8e69ee9ee9..be5b5bd872 100644
--- a/src/pal/src/CMakeLists.txt
+++ b/src/pal/src/CMakeLists.txt
@@ -5,7 +5,9 @@ if(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(CLR_CMAKE_USE_SYSTEM_LIBUNWIND 1)
endif(CMAKE_SYSTEM_NAME STREQUAL Darwin OR CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
-include_directories(SYSTEM /usr/local/include)
+if(NOT DEFINED ENV{ROOTFS_DIR})
+ include_directories(SYSTEM /usr/local/include)
+endif()
add_compile_options(-fPIC)
diff --git a/src/pal/src/examples/example1.cpp b/src/pal/src/examples/example1.cpp
index 576e76632e..fce8c367b5 100644
--- a/src/pal/src/examples/example1.cpp
+++ b/src/pal/src/examples/example1.cpp
@@ -32,7 +32,7 @@ int main(int argc, char *argv[])
HANDLE h;
unsigned int b;
- PAL_Initialize(argc, (const char**)argv);
+ PAL_Initialize(argc, argv);
SetCurrentDirectoryW(dir);
SetCurrentDirectoryW(dir);
h = CreateFileW(src, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, 0, NULL);
diff --git a/src/pal/src/exception/remote-unwind.cpp b/src/pal/src/exception/remote-unwind.cpp
index 4934e77115..fe7a4c814f 100644
--- a/src/pal/src/exception/remote-unwind.cpp
+++ b/src/pal/src/exception/remote-unwind.cpp
@@ -51,10 +51,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// Sub-headers included from the libunwind.h contain an empty struct
// and clang issues a warning. Until the libunwind is fixed, disable
// the warning.
+#ifdef __llvm__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wextern-c-compat"
+#endif
#include <libunwind.h>
+#ifdef __llvm__
#pragma clang diagnostic pop
+#endif
SET_DEFAULT_DEBUG_CHANNEL(EXCEPT);
diff --git a/src/pal/src/exception/seh-unwind.cpp b/src/pal/src/exception/seh-unwind.cpp
index 094036189c..3f40057d88 100644
--- a/src/pal/src/exception/seh-unwind.cpp
+++ b/src/pal/src/exception/seh-unwind.cpp
@@ -31,10 +31,14 @@ Abstract:
// Sub-headers included from the libunwind.h contain an empty struct
// and clang issues a warning. Until the libunwind is fixed, disable
// the warning.
+#ifdef __llvm__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wextern-c-compat"
+#endif
#include <libunwind.h>
+#ifdef __llvm__
#pragma clang diagnostic pop
+#endif
//----------------------------------------------------------------------
// Virtual Unwinding
diff --git a/src/pal/src/init/pal.cpp b/src/pal/src/init/pal.cpp
index d683ca7345..f6bbd6a82c 100644
--- a/src/pal/src/init/pal.cpp
+++ b/src/pal/src/init/pal.cpp
@@ -153,7 +153,7 @@ int
PALAPI
PAL_Initialize(
int argc,
- const char *const argv[])
+ char *const argv[])
{
return Initialize(argc, argv, PAL_INITIALIZE);
}
diff --git a/src/pal/src/libunwind/src/CMakeLists.txt b/src/pal/src/libunwind/src/CMakeLists.txt
index c035f64c11..98d3d3e7a9 100644
--- a/src/pal/src/libunwind/src/CMakeLists.txt
+++ b/src/pal/src/libunwind/src/CMakeLists.txt
@@ -7,6 +7,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
include(configure.cmake)
+if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ add_compile_options(-Wformat=0)
+ add_compile_options(-Wno-unused-value)
+endif()
+
# The HAVE___THREAD set to 1 causes creation of thread local variable with tls_model("initial-exec")
# which is incompatible with usage of the unwind code in a shared library.
add_definitions(-DHAVE___THREAD=0)
@@ -19,15 +24,19 @@ add_definitions(-D_GNU_SOURCE)
# Ensure that the remote and local unwind code can reside in the same binary without name clashing
add_definitions("-Ddwarf_search_unwind_table_int=UNW_OBJ(dwarf_search_unwind_table_int)")
-add_compile_options(-Wno-header-guard)
+if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ add_compile_options(-Wno-header-guard)
+endif()
if(CLR_CMAKE_PLATFORM_ARCH_ARM)
# Ensure that the remote and local unwind code can reside in the same binary without name clashing
add_definitions("-Darm_search_unwind_table=UNW_OBJ(arm_search_unwind_table)")
# Disable warning in asm: use of SP or PC in the list is deprecated
add_compile_options(-Wno-inline-asm)
- # Disable warning due to labs function called on unsigned argument
- add_compile_options(-Wno-absolute-value)
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # Disable warning due to labs function called on unsigned argument
+ add_compile_options(-Wno-absolute-value)
+ endif()
# Disable warning due to incorrect format specifier in debugging printf via the Debug macro
add_compile_options(-Wno-format)
# Disable warning for a bug in the libunwind source src/arm/Gtrace.c:529, but not in code that we exercise
@@ -41,8 +50,10 @@ if(CLR_CMAKE_PLATFORM_ARCH_ARM)
# the include/tdep-arm to include directories
include_directories(../include/tdep-arm)
elseif(CLR_CMAKE_PLATFORM_ARCH_ARM64)
- # Disable warning due to labs function called on unsigned argument
- add_compile_options(-Wno-absolute-value)
+ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ # Disable warning due to labs function called on unsigned argument
+ add_compile_options(-Wno-absolute-value)
+ endif()
# We compile code with -std=c99 and the asm keyword is not recognized as it is a gnu extension
add_definitions(-Dasm=__asm__)
elseif(CLR_CMAKE_PLATFORM_ARCH_I386)