Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds HPX_LINKER_FLAGS to HPX applications without editing their source codes #3371

Merged
merged 2 commits into from Jul 9, 2018
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+86 −5
Diff settings

Always

Just for now

@@ -59,6 +59,10 @@ if(HPX_WITH_STATIC_LINKING)
set(HPX_CONF_LIBRARIES "general;hpx;${HPX_LIBRARIES}")
set(HPX_PKG_LIBRARIES "\${libdir}/libhpx.a ${HPX_PKG_LIBRARIES}")
set(HPX_PKG_DEBUG_LIBRARIES "\${libdir}/libhpxd.a ${HPX_PKG_DEBUG_LIBRARIES}")
if(HPX_WITH_DYNAMIC_HPX_MAIN)
set(HPX_PKG_LIBRARIES "\${libdir}/libhpx_wrap.a ${HPX_PKG_LIBRARIES}")
set(HPX_PKG_DEBUG_LIBRARIES "\${libdir}/libhpx_wrapd.a ${HPX_PKG_DEBUG_LIBRARIES}")
endif()
else()
set(HPX_CONF_LIBRARIES "general;hpx;general;hpx_init;${HPX_LIBRARIES}")
if(APPLE)
@@ -71,6 +75,10 @@ else()
set(HPX_PKG_DEBUG_LIBRARIES_BAZEL "${HPX_CONF_PREFIX}/lib/libhpxd.so ${HPX_CONF_PREFIX}/lib/libhpx_initd.a ${HPX_PKG_DEBUG_LIBRARIES}")
set(HPX_PKG_LIBRARIES "\${libdir}/libhpx.so \${libdir}/libhpx_init.a ${HPX_PKG_LIBRARIES}")
set(HPX_PKG_DEBUG_LIBRARIES "\${libdir}/libhpxd.so \${libdir}/libhpx_initd.a ${HPX_PKG_DEBUG_LIBRARIES}")
if(HPX_WITH_DYNAMIC_HPX_MAIN)
set(HPX_PKG_LIBRARIES "\${libdir}/libhpx_wrap.a ${HPX_PKG_LIBRARIES}")
set(HPX_PKG_DEBUG_LIBRARIES "\${libdir}/libhpx_wrapd.a ${HPX_PKG_DEBUG_LIBRARIES}")
endif()
endif()
endif()

Copy path View file
@@ -188,7 +188,11 @@ function(hpx_setup_target target)
endif()

if(NOT target_NOLIBS)
set(hpx_libs hpx)
if(HPX_WITH_DYNAMIC_HPX_MAIN AND ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux"))

This comment has been minimized.

Copy link
@hkaiser

hkaiser Jul 9, 2018

Member

Shouldn't this happen for executables only?

This comment has been minimized.

Copy link
@NK-Nikunj

NK-Nikunj Jul 9, 2018

Author Member

@hkaiser if we limit it to Executables only, then some shared objects that link to it in phylanx will throw a linker error for not defined __real___libc_start_main. Providing this flag to non-executables will not produce unexpected results.

set(hpx_libs hpx_wrap)
set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,-wrap=__libc_start_main")
endif()
set(hpx_libs ${hpx_libs} hpx)
if(NOT target_STATIC_LINKING)
set(hpx_libs ${hpx_libs})
if(NOT nohpxinit)
@@ -203,9 +207,6 @@ function(hpx_setup_target target)
if(DEFINED HPX_LIBRARIES)
set(hpx_libs ${hpx_libs} ${HPX_LIBRARIES})
endif()
if(HPX_WITH_DYNAMIC_HPX_MAIN AND (("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") AND ("${_type}" STREQUAL "EXECUTABLE")))
set_target_properties(${target} PROPERTIES LINK_FLAGS "-Wl,-wrap=__libc_start_main")
endif()
else()
target_compile_options(${target} PUBLIC ${CXX_FLAG})
endif()
@@ -88,3 +88,8 @@ if(HPX_WITH_CUDA)
set(HPX_CUDA_CLANG_FLAGS @HPX_CUDA_CLANG_FLAGS@)
cuda_include_directories("@HPX_CMAKE_CONF_INCLUDE_DIRS@")
endif()

# Add HPX linker flag to CMAKE_EXE_LINKER_FLAGS
if(HPX_WITH_DYNAMIC_HPX_MAIN)
set(CMAKE_EXE_LINKER_FLAGS "@CMAKE_EXE_LINKER_FLAGS@ @HPX_LINKER_FLAGS@")
endif()
Copy path View file
@@ -45,10 +45,16 @@ add_hpx_library_sources(hpx
GLOB_RECURSE GLOBS "${PROJECT_SOURCE_DIR}/src/compat/*.cpp"
APPEND)

# libhpx_wrap sources
if(HPX_WITH_DYNAMIC_HPX_MAIN)
add_hpx_library_sources (hpx_Wrap
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()

# libhpx_init sources
add_hpx_library_sources(hpx_init
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/hpx_*.cpp"
EXCLUDE "hpx_init[.]cpp")
EXCLUDE "hpx_init[.]cpp|hpx_wrap.cpp")
add_hpx_library_sources(hpx_init
GLOB GLOBS "${PROJECT_SOURCE_DIR}/src/util/lightweight_test.cpp"
APPEND)
@@ -156,6 +162,14 @@ add_hpx_source_group(
ROOT "${PROJECT_SOURCE_DIR}/hpx"
TARGETS ${hpx_HEADERS})

if(HPX_WITH_DYNAMIC_HPX_MAIN)
add_hpx_source_group(
NAME hpx_wrap
CLASS "Source Files"
ROOT "${PROECT_SOURCE_DIR}/src"
TARGETS "${PROECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()

add_hpx_source_group(
NAME hpx_init
CLASS "Source Files"
@@ -316,11 +330,64 @@ foreach(_flag ${HPX_TARGET_COMPILE_DEFINITIONS_VAR})
endif()
endforeach()

################################################################################
# libhpx_wrap

This comment has been minimized.

Copy link
@hkaiser

hkaiser Jul 9, 2018

Member

All of this should be disabled for anything but Linux

This comment has been minimized.

Copy link
@NK-Nikunj

NK-Nikunj Jul 9, 2018

Author Member

oh yes! forgot that.

if(HPX_WITH_DYNAMIC_HPX_MAIN)
if(NOT HPX_WITH_STATIC_LINKING)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(HPX_WITH_DEFAULT_TARGETS)
if(HPX_WITH_CUDA)
cuda_add_library(hpx_wrap STATIC
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
else()
add_library(hpx_wrap STATIC
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()
else()
if(HPX_WITH_CUDA)
cuda_add_library(hpx_wrap STATIC EXCLUDE_FROM_ALL
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
else()
add_library(hpx_wrap STATIC EXCLUDE_FROM_ALL
"${PROJECT_SOURCE_DIR}/src/hpx_wrap.cpp")
endif()
endif()

set_property(TARGET hpx_wrap APPEND
PROPERTY COMPILE_DEFINITIONS
"HPX_APPLICATION_EXPORTS"
"HPX_ENABLE_ASSERT_HANDLER")

set_property(TARGET hpx_wrap PROPERTY FOLDER "Core")
set(hpx_targets ${hpx_targets} hpx_wrap)
endif()

endif()

get_property(HPX_TARGET_COMPILE_DEFINITIONS_VAR
GLOBAL PROPERTY HPX_TARGET_COMPILE_DEFINITIONS)
foreach(_flag ${HPX_TARGET_COMPILE_DEFINITIONS_VAR})
target_compile_definitions(hpx INTERFACE ${_flag})
target_compile_definitions(hpx PUBLIC ${_flag})
if(HPX_WITH_DYNAMIC_HPX_MAIN)
target_compile_definitions(hpx_wrap INTERFACE ${_flag})
target_compile_definitions(hpx_wrap PUBLIC ${_flag})
endif()
if(NOT HPX_WITH_STATIC_LINKING)
target_compile_definitions(hpx_init PUBLIC ${_flag})
endif()
endforeach()

get_property(HPX_TARGET_COMPILE_OPTIONS_VAR
GLOBAL PROPERTY HPX_TARGET_COMPILE_OPTIONS)
foreach(_flag ${HPX_TARGET_COMPILE_OPTIONS_VAR})
target_compile_options(hpx INTERFACE ${_flag})
target_compile_options(hpx PUBLIC ${_flag})
if(HPX_WITH_DYNAMIC_HPX_MAIN)
target_compile_options(hpx_wrap INTERFACE ${_flag})
target_compile_options(hpx_wrap PUBLIC ${_flag})
endif()
if(NOT HPX_WITH_STATIC_LINKING)
target_compile_options(hpx_init PUBLIC ${_flag})
endif()
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.