Skip to content

Commit

Permalink
Link with default rpath set to absolute path to LDC lib dir(s)
Browse files Browse the repository at this point in the history
But still in a portable way for the portable prebuilt packages, which
will replace the absolute install path with `%%ldcbinarypath%/..` in the
config file, which will still lead to an absolute rpath in produced
binaries.
  • Loading branch information
kinke committed Apr 20, 2018
1 parent e3d6375 commit b43a056
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 2 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,10 @@ commonSteps: &commonSteps
name: Hello world integration test with shared libs
command: |
cd ..
altLibSuffix="32"
if [ "$CI_OS" = "osx" ]; then
altLibSuffix=""
fi
echo 'void main() { import std.stdio; writeln("Hello world, ", size_t.sizeof * 8, " bits"); }' > hello.d
$LDC_INSTALL_DIR/bin/ldc2 hello.d -m64 -of=hello64 -link-defaultlib-shared -L-Wl,-rpath,$LDC_INSTALL_DIR/lib
$LDC_INSTALL_DIR/bin/ldc2 hello.d -m64 -of=hello64 -link-defaultlib-shared
./hello64
$LDC_INSTALL_DIR/bin/ldc2 hello.d -m32 -of=hello32 -link-defaultlib-shared -L-Wl,-rpath,$LDC_INSTALL_DIR/lib$altLibSuffix
$LDC_INSTALL_DIR/bin/ldc2 hello.d -m32 -of=hello32 -link-defaultlib-shared
./hello32
- run:
name: Hello world integration test with LTO
Expand Down
2 changes: 1 addition & 1 deletion ldc2_install.conf.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ default:
// default switches injected before all explicit command-line switches
switches = [
"-I@INCLUDE_INSTALL_DIR@/ldc",
"-I@INCLUDE_INSTALL_DIR@",
"-I@INCLUDE_INSTALL_DIR@",@SHARED_LIBS_INSTALL_RPATH@
"-defaultlib=phobos2-ldc,druntime-ldc"@ADDITIONAL_DEFAULT_LDC_SWITCHES@
];
// default switches appended after all explicit command-line switches
Expand Down
7 changes: 4 additions & 3 deletions runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,12 +252,13 @@ if(MULTILIB AND NOT "${TARGET_SYSTEM}" MATCHES "APPLE")
endif()

# Set the -rpath linker option when shared runtime libraries are built.
# The installed config file doesn't use SHARED_LIBS_RPATH.
if(NOT ${BUILD_SHARED_LIBS} STREQUAL "OFF")
if(MULTILIB AND NOT "${TARGET_SYSTEM}" MATCHES "APPLE")
set(SHARED_LIBS_RPATH "\n \"-L-rpath\", \"-L${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}:${CMAKE_BINARY_DIR}/lib${MULTILIB_SUFFIX}\",")
set(SHARED_LIBS_RPATH "\n \"-L-rpath\", \"-L${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}:${CMAKE_BINARY_DIR}/lib${MULTILIB_SUFFIX}\",")
set(SHARED_LIBS_INSTALL_RPATH "\n \"-L-rpath\", \"-L${CMAKE_INSTALL_LIBDIR}:${CMAKE_INSTALL_PREFIX}/lib${MULTILIB_SUFFIX}\",")
else()
set(SHARED_LIBS_RPATH "\n \"-L-rpath\", \"-L${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}\",")
set(SHARED_LIBS_RPATH "\n \"-L-rpath\", \"-L${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}\",")
set(SHARED_LIBS_INSTALL_RPATH "\n \"-L-rpath\", \"-L${CMAKE_INSTALL_LIBDIR}\",")
endif()
endif()

Expand Down

0 comments on commit b43a056

Please sign in to comment.