Skip to content

Commit

Permalink
Change the runpath to an architecture-specific directory on ELF platf…
Browse files Browse the repository at this point in the history
…orms

This is needed for swiftlang/swift#63782, which changes the Unix toolchain to look
for libraries in architecture-specific directories.
  • Loading branch information
finagolfin committed Mar 4, 2023
1 parent 495b4be commit f6fad0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 2 additions & 0 deletions lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ config.test_exec_root = lit_config.params.get(
# target and stick it in here.
if platform.system() == 'Linux':
config.target_triple = 'linux'
linux_run_arch = subprocess.check_output(["uname", "-m"]).strip().decode("utf-8")
elif platform.system() == 'Darwin':
config.target_triple = 'darwin'

Expand Down Expand Up @@ -234,6 +235,7 @@ config.substitutions.append( ('%{not}', os.path.join(srcroot, "not")) )
config.substitutions.append( ('%{lldb}', lldb_path) )
if platform.system() == 'Linux':
config.substitutions.append( ('%{repl_swift}', repl_swift_dummy_path) )
config.substitutions.append( ('%{linux_arch}', linux_run_arch) )
config.substitutions.append( ('%{swift}', swift_path) )
config.substitutions.append( ('%{swiftc}', swiftc_path) )
config.substitutions.append( ('%{FileCheck}', filecheck_path) )
Expand Down
18 changes: 12 additions & 6 deletions test-snapshot-binaries/test-rpath-linux.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
# Tests that DT_RPATH is correct for the dummy repl executable on Linux.
# REQUIRES: platform=Linux
# RUN: %{readelf} -d %{repl_swift} | %{FileCheck} %s
# CHECK: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN/../lib/swift/linux
# CHECK: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN/../lib/swift/linux/
#
# Tests that DT_RUNPATH is correct for the Swift stdlib and other libraries on Linux.
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftCore.so | %{FileCheck} --check-prefix CHECK-CORE %s
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/%{linux_arch}/libswiftCore.so | %{FileCheck} --check-prefix CHECK-CORE %s
# CHECK-CORE: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN{{[^/]}}
# CHECK-CORE-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
#
# RUN: %{readelf} -d %{package_path}/usr/lib/libsourcekitdInProc.so | %{FileCheck} --check-prefix CHECK-SK %s
# CHECK-SK: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN/swift/linux/
# CHECK-SK-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
#
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftRemoteMirror.so | %{FileCheck} --check-prefix CHECK-RM %s
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/%{linux_arch}/libswiftRemoteMirror.so | %{FileCheck} --check-prefix CHECK-RM %s
# CHECK-RM: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN{{[^/]}}
# CHECK-RM-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
#
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswift_Differentiation.so | %{FileCheck} --check-prefix CHECK-SD %s
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/%{linux_arch}/libswift_Differentiation.so | %{FileCheck} --check-prefix CHECK-SD %s
# CHECK-SD: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN{{[^/]}}
# CHECK-SD-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
#
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftGlibc.so | %{FileCheck} --check-prefix CHECK-SG %s
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/%{linux_arch}/libswiftGlibc.so | %{FileCheck} --check-prefix CHECK-SG %s
# CHECK-SG: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN{{[^/]}}
# CHECK-SG-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
#
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/libswiftSwiftOnoneSupport.so | %{FileCheck} --check-prefix CHECK-SON %s
# RUN: %{readelf} -d %{package_path}/usr/lib/swift/linux/%{linux_arch}/libswiftSwiftOnoneSupport.so | %{FileCheck} --check-prefix CHECK-SON %s
# CHECK-SON: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}$ORIGIN{{[^/]}}
# CHECK-SON-NOT: {{.*}} {{\(RPATH\)|\(RUNPATH\)}} {{.*}}:/usr/lib/swift/linux
#
# RUN: %{readelf} -d %{package_path}/usr/lib/libswiftDemangle.so | %{FileCheck} --check-prefix CHECK-SDE %s
Expand Down

0 comments on commit f6fad0d

Please sign in to comment.