Skip to content

Commit

Permalink
Merge pull request #6278 from dnakamura/static_libcpp
Browse files Browse the repository at this point in the history
CMake: Link jit statically against c++ standard lib
  • Loading branch information
DanHeidinga committed Oct 22, 2019
2 parents 502f3f3 + 483fd1b commit c26bcb7
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions runtime/compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
################################################################################

include(CheckCXXCompilerFlag)
# This CMakeLists is included by the VM CMake lists, and works after composition
# has occurred.
#
Expand Down Expand Up @@ -49,6 +50,10 @@ if(OMR_ARCH_X86)
omr_append_flags(CMAKE_ASM_NASM_FLAGS ${asm_inc_dirs})
endif()

if(OMR_TOOLCONFIG STREQUAL "gnu")
check_cxx_compiler_flag("-static-libstdc++" ALLOWS_STATIC_LIBCPP)
endif()

# On windows exceptions are controlled via a the preprocessor define _HAS_EXCEPTIONS
# We need to enable it again, after omr platform config removed it
get_directory_property(compile_defs COMPILE_DEFINITIONS)
Expand Down Expand Up @@ -348,6 +353,12 @@ if(OMR_OS_LINUX)
elseif(OMR_OS_WINDOWS)
target_sources(j9jit PRIVATE build/scripts/j9jit.def)
endif()
if((OMR_TOOLCONFIG STREQUAL "gnu") AND ALLOWS_STATIC_LIBCPP)
# We assume that if the compiler allows -static-libstdc++
# it will also allow -static-libgcc
set_property(TARGET j9jit APPEND_STRING PROPERTY
LINK_FLAGS " -static-libgcc -static-libstdc++")
endif()
set_property(TARGET j9jit PROPERTY LINKER_LANGUAGE CXX)

# Note ddrgen can't handle the templated symbols used in the jit
Expand Down

0 comments on commit c26bcb7

Please sign in to comment.