[MacPorts] #69812: /usr/bin/clang++ cannot compile anything when trying to compile as x86_64 on a current arm system against the MacOSX10.13.sdk

MacPorts noreply at macports.org
Sun Jun 9 20:14:36 UTC 2024


#69812: /usr/bin/clang++ cannot compile anything when trying to compile as x86_64
on a current arm system against the MacOSX10.13.sdk
---------------------+--------------------
  Reporter:  lukaso  |      Owner:  (none)
      Type:  defect  |     Status:  new
  Priority:  Normal  |  Milestone:
 Component:  ports   |    Version:
Resolution:          |   Keywords:
      Port:          |
---------------------+--------------------

Comment (by kencu):

 so clang has changed the way it looks for c++ headers.

 It looks here now:
 {{{
 <SDK>/usr/include/c++/v1
 }}}

 but the 10.13 SDK doesn't have that path, it has this:
 {{{
 <SDK>/usr/include/c++/4.2.1
 }}}

 so that is easy to solve with a trivial symlink:
 {{{
 sudo ln -s 4.2.1 v1

 % ls -la
 total 0
 drwxr-xr-x@   4 root  wheel   128  9 Jun 13:03 .
 drwxr-xr-x@ 267 root  wheel  8544 26 Mar  2018 ..
 drwxr-xr-x@  58 root  wheel  1856  6 Oct  2017 4.2.1
 lrwxr-xr-x    1 root  wheel     5  9 Jun 13:03 v1 -> 4.2.1
 }}}

 and that gets you farther, but still no bueno:
 {{{
 % /usr/bin/clang++  -pipe -Os -arch x86_64 -isysroot
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk hello.cpp
 Undefined symbols for architecture x86_64:
   "std::ios_base::Init::Init()", referenced from:
       __GLOBAL__sub_I_hello.cpp in hello-3a43aa.o
   "std::ios_base::Init::~Init()", referenced from:
       __GLOBAL__sub_I_hello.cpp in hello-3a43aa.o
   "std::basic_ostream<char, std::char_traits<char>>&
 std::__ostream_insert<char,
 std::char_traits<char>>(std::basic_ostream<char, std::char_traits<char>>&,
 char const*, long)", referenced from:
       _main in hello-3a43aa.o
   "std::cout", referenced from:
       _main in hello-3a43aa.o
 ld: symbol(s) not found for architecture x86_64
 }}}

 and exactly why the linker can't find the symbols is not yet clear...
 {{{
 % /usr/bin/clang++  -v -Wl,-v -pipe -Os -arch x86_64 -isysroot
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk hello.cpp
 Apple clang version 15.0.0 (clang-1500.3.9.4)
 Target: x86_64-apple-darwin23.5.0
 Thread model: posix
 InstalledDir:
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
 -cc1 -triple x86_64-apple-macosx10.13.0 -Wdeprecated-objc-isa-usage
 -Werror=deprecated-objc-isa-usage -Werror=implicit-function-declaration
 -emit-obj --mrelax-relocations -disable-free -clear-ast-before-backend
 -disable-llvm-verifier -discard-value-names -main-file-name hello.cpp
 -mrelocation-model pic -pic-level 2 -mframe-pointer=all -fno-strict-return
 -ffp-contract=on -fno-rounding-math -funwind-tables=2 -target-sdk-
 version=10.13 -fcompatibility-qualified-id-block-type-checking
 -fvisibility-inlines-hidden-static-local-var -target-cpu penryn -tune-cpu
 generic -debugger-tuning=lldb -target-linker-version 1053.12 -v
 -fcoverage-compilation-dir=/Users/cunningh -resource-dir
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0
 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk
 -internal-isystem
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/include/c++/v1
 -internal-isystem
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/local/include
 -internal-isystem
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include
 -internal-externc-isystem
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/include
 -internal-externc-isystem
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 -Os -Wno-reorder-init-list -Wno-implicit-int-float-conversion
 -Wno-c99-designator -Wno-final-dtor-non-final-class -Wno-extra-semi-stmt
 -Wno-misleading-indentation -Wno-quoted-include-in-framework-header -Wno-
 implicit-fallthrough -Wno-enum-enum-conversion -Wno-enum-float-conversion
 -Wno-elaborated-enum-base -Wno-reserved-identifier -Wno-gnu-folding-
 constant -fdeprecated-macro -fdebug-compilation-dir=/Users/cunningh
 -ferror-limit 19 -stack-protector 1 -mdarwin-stkchk-strong-link -fblocks
 -fencode-extended-block-signature -fregister-global-dtors-with-atexit
 -fgnuc-version=4.2.1 -fno-cxx-modules -fcxx-exceptions -fexceptions -fmax-
 type-align=16 -fcommon -fcolor-diagnostics -vectorize-loops -vectorize-slp
 -clang-vendor-feature=+disableNonDependentMemberExprInCurrentInstantiation
 -fno-odr-hash-protocols -clang-vendor-feature=+enableAggressiveVLAFolding
 -clang-vendor-feature=+revert09abecef7bbf -clang-vendor-
 feature=+thisNoAlignAttr -clang-vendor-feature=+thisNoNullAttr -mllvm
 -disable-aligned-alloc-awareness=1 -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o
 /var/folders/97/nn3swcb52bg003_4bctdbyd80000gn/T/hello-f75c30.o -x c++
 hello.cpp
 clang -cc1 version 15.0.0 (clang-1500.3.9.4) default target x86_64-apple-
 darwin23.5.0
 ignoring nonexistent directory
 "/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/local/include"
 ignoring nonexistent directory
 "/Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/Library/Frameworks"
 #include "..." search starts here:
 #include <...> search starts here:
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/include/c++/v1
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/include
  /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/System/Library/Frameworks
 (framework directory)
 End of search list.
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
 -demangle -lto_library
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/libLTO.dylib
 -dynamic -arch x86_64 -platform_version macos 10.13.0 10.13 -syslibroot
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk -Os -o a.out -v
 /var/folders/97/nn3swcb52bg003_4bctdbyd80000gn/T/hello-f75c30.o -lc++
 -lSystem
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/15.0.0/lib/darwin/libclang_rt.osx.a
 @(#)PROGRAM:ld PROJECT:ld-1053.12
 BUILD 10:14:46 Mar 29 2024
 configured to support archs: armv6 armv7 armv7s arm64 arm64e arm64_32 i386
 x86_64 x86_64h armv6m armv7k armv7m armv7em
 will use ld-classic for: armv6 armv7 armv7s arm64_32 i386 armv6m armv7k
 armv7m armv7em
 LTO support using: LLVM version 15.0.0 (static support for 29, runtime is
 29)
 TAPI support using: Apple TAPI version 15.0.0 (tapi-1500.3.2.2)
 Library search paths:
         /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/usr/lib
 Framework search paths:
 /Library/Developer/CommandLineTools/SDKs/MacOSX10.13.sdk/System/Library/Frameworks
 Undefined symbols for architecture x86_64:
   "std::ios_base::Init::Init()", referenced from:
       __GLOBAL__sub_I_hello.cpp in hello-f75c30.o
   "std::ios_base::Init::~Init()", referenced from:
       __GLOBAL__sub_I_hello.cpp in hello-f75c30.o
   "std::basic_ostream<char, std::char_traits<char>>&
 std::__ostream_insert<char,
 std::char_traits<char>>(std::basic_ostream<char, std::char_traits<char>>&,
 char const*, long)", referenced from:
       _main in hello-f75c30.o
   "std::cout", referenced from:
       _main in hello-f75c30.o
 ld: symbol(s) not found for architecture x86_64
 clang: error: linker command failed with exit code 1 (use -v to see
 invocation)
 }}}


 and now I just have to remind myself why we are trying to bash our heads
 in building against the 10.13 SDK again ...

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


More information about the macports-tickets mailing list