summaryrefslogtreecommitdiff
path: root/src/pal/tools
diff options
context:
space:
mode:
authorGeunsik Lim <leemgs@users.noreply.github.com>2016-05-11 17:44:36 +0900
committerJan Vorlicek <janvorli@microsoft.com>2016-05-11 10:44:36 +0200
commitee28eca285fc71acad093eb5e34101d2ab9e2018 (patch)
tree47f889826403ee90a3debd46cc0311994dbd135b /src/pal/tools
parent5c3d1efea4a8673086df4ba36267d7f580ba9c8c (diff)
downloadcoreclr-ee28eca285fc71acad093eb5e34101d2ab9e2018.tar.gz
coreclr-ee28eca285fc71acad093eb5e34101d2ab9e2018.tar.bz2
coreclr-ee28eca285fc71acad093eb5e34101d2ab9e2018.zip
Linux/ARM: Use -O1 level to avoid segfault in release-build for Linux/ARM (#4904)
We cannot still run 'hello world' console application even though the cross compilation of CoreCLR is successfully completed. In release-build, the segmentation fault of 'hello world' is made by the misalignment of thread local storage (TLS) section because of the aggressive optimization level of clang compiler for code optimization(e.g., file size and execution speed). It means that Clang/LLVM has a bug in case of the usage of O2/O3 flag. Below is the major difference among the optimization levels of Clang. * -O2 is based on -O1: .adding: -gvn -constmerge -globaldce -slp-vectorizer -mldst-motion -inline .removing: -always-inline * -O3 is based on -O2: .adding: -argpromotion ver2: - Corerun is loading 'libcoreclr.so' using dlopen() library call. So, we can not use initial-exec TLS model (ver1) because of the thread-safe issue of the multi-threaded. (Reported by @janvorli) - In the release-build, Let's replace -O3 with -O1 to avoid the segmentation fault due to the aggressive optimization level of the Clang until fixing the bug of the Clang/LLVM. ver1: - The default value of clang is "global-dynamic". However, the thread-local storage (TLS) model of Clang/LLVM does not guarantee the normal execution of TLS's symbol relocation due to the misaligned __tls_get_addr symbol in case of the aggressive optimizations of Clang on Linux/ARM. - Let's enable initial-exec TLS model instead of the dynamic TLS model. Signed-off-by: Geunsik Lim <geunsik.lim@samsung.com> CC: Jan Kotas <jkotas@microsoft.com> CC: Jan Vorlicek <janvorli@microsoft.com>
Diffstat (limited to 'src/pal/tools')
-rw-r--r--src/pal/tools/clang-compiler-override.txt13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/pal/tools/clang-compiler-override.txt b/src/pal/tools/clang-compiler-override.txt
index 8bba4a962b..468e06adce 100644
--- a/src/pal/tools/clang-compiler-override.txt
+++ b/src/pal/tools/clang-compiler-override.txt
@@ -1,13 +1,22 @@
SET (CMAKE_C_FLAGS_INIT "-Wall -std=c11")
SET (CMAKE_C_FLAGS_DEBUG_INIT "-g -O0")
SET (CLR_C_FLAGS_CHECKED_INIT "-g -O2")
-SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O3")
+# Todo: Replace -O1 with -O3 after fixing Clang/LLVM for __thread on Linux/ARM
+if(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+ SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O1")
+else()
+ SET (CMAKE_C_FLAGS_RELEASE_INIT "-g -O3")
+endif()
SET (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-g -O2")
SET (CMAKE_CXX_FLAGS_INIT "-Wall -Wno-null-conversion -std=c++11")
SET (CMAKE_CXX_FLAGS_DEBUG_INIT "-g -O0")
SET (CLR_CXX_FLAGS_CHECKED_INIT "-g -O2")
-SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O3")
+if(CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL armv7l)
+ SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O1")
+else()
+ SET (CMAKE_CXX_FLAGS_RELEASE_INIT "-g -O3")
+endif()
SET (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-g -O2")
SET (CLR_DEFINES_DEBUG_INIT DEBUG _DEBUG _DBG URTBLDENV_FRIENDLY=Checked BUILDENV_CHECKED=1)