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

darwin: RPATH is set at build time but is removed at install time #11109

Open
jeremyhu opened this issue Nov 25, 2022 · 0 comments
Open

darwin: RPATH is set at build time but is removed at install time #11109

jeremyhu opened this issue Nov 25, 2022 · 0 comments
Labels
OS:macos Issues specific to Apple Operating Systems like MacOS and iOS

Comments

@jeremyhu
Copy link

Describe the bug

I'm building with -Wl,-rpath,/opt/X11/lib/asan in LDFLAGS. During build, this is passed as expected and the resulting binary has the correct LC_RPATH load command. When I install, the resulting binary does NOT have this load command.

I tried using -Wl,-rpath -Wl,/opt/X11/lib/asan to see if that woudl trick meson into working, but it failed just the same.

To Reproduce

I'm using libxcvt from xorg as it's a small and simple meson-based project that exhibits this easily.

+ export 'CPPFLAGS=-I/opt/X11/include -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -DFAIL_HARD'
+ CPPFLAGS='-I/opt/X11/include -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -DFAIL_HARD'
+ export 'CFLAGS= -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address'
+ CFLAGS=' -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address'
+ export 'LDFLAGS= -target fat-apple-macos10.10 -arch arm64 -L/opt/X11/lib -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -Wl,-rpath -Wl,/opt/X11/lib/asan -Wl,/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib'
+ LDFLAGS=' -target fat-apple-macos10.10 -arch arm64 -L/opt/X11/lib -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -Wl,-rpath -Wl,/opt/X11/lib/asan -Wl,/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib'
+ export 'CXXFLAGS= -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address'
+ CXXFLAGS=' -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address'
+ export 'OBJCFLAGS= -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address'
+ OBJCFLAGS=' -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address'
+ export CC=/usr/bin/clang
+ CC=/usr/bin/clang
+ export CXX=/usr/bin/clang++
+ CXX=/usr/bin/clang++
+ export OBJC=/usr/bin/clang
+ OBJC=/usr/bin/clang
+ export CC_FOR_BUILD=/usr/bin/clang
+ CC_FOR_BUILD=/usr/bin/clang
+ export CXX_FOR_BUILD=/usr/bin/clang++
+ CXX_FOR_BUILD=/usr/bin/clang++
+ meson build.arm64 -Dprefix=/opt/X11 --cross-file /Users/jeremy/src/freedesktop/github/XQuartz/meson_support/meson/cross/arm64-darwin-xquartz
The Meson build system
Version: 0.63.3
Source dir: /Users/jeremy/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt
Build dir: /Users/jeremy/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt/build.arm64
Build type: cross build
Project name: libxcvt
Project version: 0.1.2
C compiler for the host machine: /usr/bin/clang (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
C linker for the host machine: /usr/bin/clang ld64 820.1
C compiler for the build machine: /usr/bin/clang (clang 14.0.0 "Apple clang version 14.0.0 (clang-1400.0.29.202)")
C linker for the build machine: /usr/bin/clang ld64 820.1
Build machine cpu family: aarch64
Build machine cpu: arm64
Host machine cpu family: aarch64
Host machine cpu: arm64
Target machine cpu family: aarch64
Target machine cpu: arm64
Library m found: YES
Configuring cvt.1 using configuration
Build targets in project: 2

libxcvt 0.1.2

  User defined options
    Cross files: /Users/jeremy/src/freedesktop/github/XQuartz/meson_support/meson/cross/arm64-darwin-xquartz
    prefix     : /opt/X11

Found ninja-1.11.1 at /opt/buildX11/bin/ninja
+ ninja --verbose -C build.arm64
ninja: Entering directory `build.arm64'
[1/5] /usr/bin/clang -Ilib/libxcvt.0.dylib.p -Ilib -I../lib -Iinclude -I../include -I/opt/X11/include -fcolor-diagnostics -Wall -Winvalid-pch -O2 -g -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -DFAIL_HARD -MD -MQ lib/libxcvt.0.dylib.p/libxcvt.c.o -MF lib/libxcvt.0.dylib.p/libxcvt.c.o.d -o lib/libxcvt.0.dylib.p/libxcvt.c.o -c ../lib/libxcvt.c
[2/5] /usr/bin/clang -Icvt/cvt.p -Icvt -I../cvt -Iinclude -I../include -I/opt/X11/include -fcolor-diagnostics -Wall -Winvalid-pch -O2 -g -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -DFAIL_HARD -MD -MQ cvt/cvt.p/cvt.c.o -MF cvt/cvt.p/cvt.c.o.d -o cvt/cvt.p/cvt.c.o -c ../cvt/cvt.c
[3/5] /usr/bin/clang  -o lib/libxcvt.0.dylib lib/libxcvt.0.dylib.p/libxcvt.c.o -L/opt/X11/lib -I/opt/X11/include -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error -shared -install_name @rpath/libxcvt.0.dylib -compatibility_version 1.0.0 -current_version 1.0.0 -target fat-apple-macos10.10 -arch arm64 -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -Wl,-rpath -Wl,/opt/X11/lib/asan -Wl,/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -DFAIL_HARD
[4/5] /opt/buildX11/Library/Frameworks/Python.framework/Versions/3.10/bin/meson --internal symbolextractor /Users/jeremy/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt/build.arm64 lib/libxcvt.0.dylib lib/libxcvt.0.dylib lib/libxcvt.0.dylib.p/libxcvt.0.dylib.symbols --cross-host=darwin
[5/5] /usr/bin/clang  -o cvt/cvt cvt/cvt.p/cvt.c.o -L/opt/X11/lib -I/opt/X11/include -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error -target fat-apple-macos10.10 -arch arm64 -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -Wl,-rpath -Wl,/opt/X11/lib/asan -Wl,/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib -target fat-apple-macos10.10 -arch arm64 -O0 -fno-optimize-sibling-calls -fno-omit-frame-pointer -g3 -gdwarf-2 -fstack-protector-all -Werror=unguarded-availability-new -Werror=objc-method-access -fsanitize=address -F/Applications/Utilities/XQuartz.app/Contents/Frameworks -DFAIL_HARD -Wl,-rpath,@loader_path/../lib lib/libxcvt.0.dylib -lm
+ sudo DESTDIR=/Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64 ninja --verbose -C build.arm64 install
ninja: Entering directory `build.arm64'
[0/1] /opt/buildX11/Library/Frameworks/Python.framework/Versions/3.10/bin/meson install --no-rebuild
Installing lib/libxcvt.0.dylib to /Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64/opt/X11/lib
Installing cvt/cvt to /Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64/opt/X11/bin
Installing /Users/jeremy/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt/include/libxcvt/libxcvt.h to /Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64/opt/X11/include/libxcvt/
Installing /Users/jeremy/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt/include/libxcvt/libxcvt_mode.h to /Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64/opt/X11/include/libxcvt/
Installing /Users/jeremy/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt/build.arm64/man/cvt.1 to /Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64/opt/X11/share/man/man1
Installing /Users/jeremy/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt/build.arm64/meson-private/libxcvt.pc to /Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64/opt/X11/lib/pkgconfig
Installing symlink pointing to libxcvt.0.dylib to /Users/jeremy/src/freedesktop/github/XQuartz/products/XQuartz.dest.lipo.arm64/opt/X11/lib/libxcvt.dylib

Expected behavior

I expect the installed binary to have /opt/X11/lib/asan in an LC_RPATH load command, but it doesn't.

$ otool -l ./build.arm64/cvt/cvt | grep -B1 -A2 LC_RPATH
Load command 16
          cmd LC_RPATH
      cmdsize 32
         path /opt/X11/lib/asan (offset 12)
Load command 17
          cmd LC_RPATH
      cmdsize 32
         path @loader_path/../lib (offset 12)
Load command 18
          cmd LC_RPATH
      cmdsize 32
         path @executable_path (offset 12)
Load command 19
          cmd LC_RPATH
      cmdsize 128
         path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/14.0.0/lib/darwin (offset 12)

[1037] ~/src/freedesktop/github/XQuartz/src/xorg/lib/libxcvt (master) $ otool -l /opt/X11/bin/cvt | grep -B1 -A2 LC_RPATH
# nada

system parameters

  • macOS 13
  • python 3.10.8
  • meson 0.63.3
  • ninja 1.11.1
jeremyhu added a commit to XQuartz/XQuartz that referenced this issue Nov 27, 2022
cf: mesonbuild/meson#11109
Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
@eli-schwartz eli-schwartz added the OS:macos Issues specific to Apple Operating Systems like MacOS and iOS label Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS:macos Issues specific to Apple Operating Systems like MacOS and iOS
Projects
None yet
Development

No branches or pull requests

2 participants