[MacPorts] #72537: clang++ don't use right -lc++

MacPorts noreply at macports.org
Sat May 24 16:12:25 UTC 2025


#72537: clang++ don't use right -lc++
--------------------------------+--------------------
  Reporter:  Serge3leo          |      Owner:  (none)
      Type:  defect             |     Status:  new
  Priority:  Normal             |  Milestone:
 Component:  ports              |    Version:
Resolution:                     |   Keywords:
      Port:  clang-20 clang-19  |
--------------------------------+--------------------
Description changed by Serge3leo:

Old description:

> Sonoma 14.7.4 (23H420)
>
> For hw.cpp:
>
> {{{
> #include <print>
> int main() { std::println("Hello world, {}", 42); return 0; }
> }}}
>
> Compile fail by undefined symbols:
>
> {{{
> $ clang++-mp-20 -v -std=c++26 hw.cpp
> clang version 20.1.4
> Target: x86_64-apple-darwin23.6.0
> Thread model: posix
> InstalledDir: /opt/local/libexec/llvm-20/bin
>  "/opt/local/libexec/llvm-20/bin/clang" -cc1 -triple x86_64-apple-
> macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-
> objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -dumpdir a-
> -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-
> value-names -main-file-name hw.cpp -mrelocation-model pic -pic-level 2
> -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2
> -target-sdk-version=14.2 -fcompatibility-qualified-id-block-type-checking
> -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-
> modules -fdefine-target-os-macros -target-cpu penryn -tune-cpu generic
> -debugger-tuning=lldb -fdebug-compilation-
> dir=/Users/leo/soft/c++17/literal -target-linker-version 1053.12 -v
> -fcoverage-compilation-dir=/Users/leo/soft/c++17/literal -resource-dir
> /opt/local/libexec/llvm-20/lib/clang/20 -isysroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
> -I/usr/local/include -internal-isystem
> /opt/local/libexec/llvm-20/bin/../include/c++/v1 -internal-isystem
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include
> -internal-isystem /opt/local/libexec/llvm-20/lib/clang/20/include
> -internal-externc-isystem
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
> -std=c++26 -fdeprecated-macro -ferror-limit 19 -stack-protector 1
> -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-
> atexit -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf
> -fcxx-exceptions -fexceptions -fmax-type-align=16 -fcolor-diagnostics
> -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o
> /var/folders/wy/z0gbkfgs7mv24ryqkdm90rm40009rh/T/hw-c117eb.o -x c++
> hw.cpp
> clang -cc1 version 20.1.4 based upon LLVM 20.1.4 default target x86_64
> -apple-darwin23.6.0
> ignoring nonexistent directory
> "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
> ignoring nonexistent directory
> "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/SubFrameworks"
> ignoring nonexistent directory
> "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
> #include "..." search starts here:
> #include <...> search starts here:
>  /usr/local/include
>  /opt/local/libexec/llvm-20/bin/../include/c++/v1
>  /opt/local/libexec/llvm-20/lib/clang/20/include
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
> (framework directory)
> End of search list.
>  "/opt/local/libexec/llvm-20/bin/ld" -demangle -lto_library
> /opt/local/libexec/llvm-20/lib/libLTO.dylib -no_deduplicate -dynamic
> -arch x86_64 -platform_version macos 14.0.0 14.2 -syslibroot
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
> -mllvm -enable-linkonceodr-outlining -o a.out -L/usr/local/lib
> /var/folders/wy/z0gbkfgs7mv24ryqkdm90rm40009rh/T/hw-c117eb.o -lc++
> -lSystem
> /opt/local/libexec/llvm-20/lib/clang/20/lib/darwin/libclang_rt.osx.a
> ld: Undefined symbols:
>   std::__1::__is_posix_terminal(__sFILE*), referenced from:
>       std::__1::__print::__is_terminal[abi:ne200100](__sFILE*) in hw-
> c117eb.o
> clang++: error: linker command failed with exit code 1 (use -v to see
> invocation)
> }}}
>
> Also, presumably, there is a bug in the dependencies of the dynamic
> library libc++.1.0.dylib. Because libunwind.1.dylib is located in a
> different directory.
>
> {{{
> $ otool -L /opt/local/libexec/llvm-20/lib/libc++/libc++.1.0.dylib
> /opt/local/libexec/llvm-20/lib/libc++/libc++.1.0.dylib:
>         @rpath/libc++.1.dylib (compatibility version 1.0.0, current
> version 1.0.0)
>         @rpath/libc++abi.1.dylib (compatibility version 1.0.0, current
> version 1.0.0)
>         @rpath/libunwind.1.dylib (compatibility version 1.0.0, current
> version 1.0.0)
>         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
> version 1345.100.2)
> }}}
>
> Workaround:
>
> {{{
> $ clang++-mp-20 -std=c++26 hw.cpp -L/opt/local/libexec/llvm-20/lib/libc++
> -rpath /opt/local/libexec/llvm-20/lib/libc++ -rpath
> /opt/local/libexec/llvm-20/lib/libunwind
> }}}

New description:

 Sonoma 14.7.4 (23H420)

 For hw.cpp:

 {{{
 #include <print>
 int main() { std::println("Hello world, {}", 42); return 0; }
 }}}

 Compile fail by undefined symbols:

 {{{
 $ clang++-mp-20 -v -std=c++26 hw.cpp
 clang version 20.1.4
 Target: x86_64-apple-darwin23.6.0
 Thread model: posix
 InstalledDir: /opt/local/libexec/llvm-20/bin
  "/opt/local/libexec/llvm-20/bin/clang" -cc1 -triple x86_64-apple-
 macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-
 objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -dumpdir a-
 -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-
 value-names -main-file-name hw.cpp -mrelocation-model pic -pic-level 2
 -mframe-pointer=all -ffp-contract=on -fno-rounding-math -funwind-tables=2
 -target-sdk-version=14.2 -fcompatibility-qualified-id-block-type-checking
 -fvisibility-inlines-hidden-static-local-var -fbuiltin-headers-in-system-
 modules -fdefine-target-os-macros -target-cpu penryn -tune-cpu generic
 -debugger-tuning=lldb -fdebug-compilation-
 dir=/Users/leo/soft/c++17/literal -target-linker-version 1053.12 -v
 -fcoverage-compilation-dir=/Users/leo/soft/c++17/literal -resource-dir
 /opt/local/libexec/llvm-20/lib/clang/20 -isysroot
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
 -I/usr/local/include -internal-isystem
 /opt/local/libexec/llvm-20/bin/../include/c++/v1 -internal-isystem
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include
 -internal-isystem /opt/local/libexec/llvm-20/lib/clang/20/include
 -internal-externc-isystem
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 -std=c++26 -fdeprecated-macro -ferror-limit 19 -stack-protector 1 -fblocks
 -fencode-extended-block-signature -fregister-global-dtors-with-atexit
 -fgnuc-version=4.2.1 -fno-implicit-modules -fskip-odr-check-in-gmf -fcxx-
 exceptions -fexceptions -fmax-type-align=16 -fcolor-diagnostics
 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o
 /var/folders/wy/z0gbkfgs7mv24ryqkdm90rm40009rh/T/hw-c117eb.o -x c++ hw.cpp
 clang -cc1 version 20.1.4 based upon LLVM 20.1.4 default target x86_64
 -apple-darwin23.6.0
 ignoring nonexistent directory
 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/local/include"
 ignoring nonexistent directory
 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/SubFrameworks"
 ignoring nonexistent directory
 "/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/Library/Frameworks"
 #include "..." search starts here:
 #include <...> search starts here:
  /usr/local/include
  /opt/local/libexec/llvm-20/bin/../include/c++/v1
  /opt/local/libexec/llvm-20/lib/clang/20/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks
 (framework directory)
 End of search list.
  "/opt/local/libexec/llvm-20/bin/ld" -demangle -lto_library
 /opt/local/libexec/llvm-20/lib/libLTO.dylib -no_deduplicate -dynamic -arch
 x86_64 -platform_version macos 14.0.0 14.2 -syslibroot
 /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
 -mllvm -enable-linkonceodr-outlining -o a.out -L/usr/local/lib
 /var/folders/wy/z0gbkfgs7mv24ryqkdm90rm40009rh/T/hw-c117eb.o -lc++
 -lSystem
 /opt/local/libexec/llvm-20/lib/clang/20/lib/darwin/libclang_rt.osx.a
 ld: Undefined symbols:
   std::__1::__is_posix_terminal(__sFILE*), referenced from:
       std::__1::__print::__is_terminal[abi:ne200100](__sFILE*) in hw-
 c117eb.o
 clang++: error: linker command failed with exit code 1 (use -v to see
 invocation)
 }}}

 Also, presumably, there is a bug in the dependencies of the dynamic
 library libc++.1.0.dylib. Because libunwind.1.dylib is located in a
 different directory.

 {{{
 $ otool -L /opt/local/libexec/llvm-20/lib/libc++/libc++.1.0.dylib
 /opt/local/libexec/llvm-20/lib/libc++/libc++.1.0.dylib:
         @rpath/libc++.1.dylib (compatibility version 1.0.0, current
 version 1.0.0)
         @rpath/libc++abi.1.dylib (compatibility version 1.0.0, current
 version 1.0.0)
         @rpath/libunwind.1.dylib (compatibility version 1.0.0, current
 version 1.0.0)
         /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current
 version 1345.100.2)
 }}}

 Workaround:

 {{{
 $ clang++-mp-20 -std=c++26 hw.cpp -L/opt/local/libexec/llvm-20/lib/libc++
 \
         -rpath /opt/local/libexec/llvm-20/lib/libc++ -rpath
 /opt/local/libexec/llvm-20/lib/libunwind
 }}}

--

-- 
Ticket URL: <https://trac.macports.org/ticket/72537#comment:1>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list