Closed smurfd closed 7 months ago
Solved it,
First i linked the current Xcode Command line tools SDK to 11.3
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX14.2.sdk /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk
Then added these two lined to my ~.zshrc
alias clang="/opt/pkg/bin/clang --target=aarch64-apple-darwin23.2.0 -fuse-ld=lld"
alias clang++="/opt/pkg/bin/clang++ --target=aarch64-apple-darwin23.2.0 -fuse-ld=lld"
$ clang -v c.c
clang version 16.0.6
Target: aarch64-apple-darwin23.2.0
Thread model: posix
InstalledDir: /opt/pkg/bin
"/opt/pkg/bin/clang-16" -cc1 -triple arm64-apple-macosx14.0.0 -Wundef-prefix=TARGET_OS_ -Werror=undef-prefix -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name c.c -mrelocation-model pic -pic-level 2 -mframe-pointer=non-leaf -ffp-contract=on -fno-rounding-math -funwind-tables=1 -fcompatibility-qualified-id-block-type-checking -fvisibility-inlines-hidden-static-local-var -target-cpu apple-m1 -target-feature +v8.5a -target-feature +crc -target-feature +crypto -target-feature +dotprod -target-feature +fp-armv8 -target-feature +fp16fml -target-feature +lse -target-feature +ras -target-feature +rcpc -target-feature +rdm -target-feature +neon -target-feature +zcm -target-feature +zcz -target-feature +fullfp16 -target-feature +sm4 -target-feature +sha3 -target-feature +sha2 -target-feature +aes -target-abi darwinpcs -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=lldb -target-linker-version 1015.7 -v -fcoverage-compilation-dir=/Users/willygorilla/dev -resource-dir /opt/pkg/lib/clang/16 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -internal-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/local/include -internal-isystem /opt/pkg/lib/clang/16/include -internal-externc-isystem /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include -fdebug-compilation-dir=/Users/willygorilla/dev -ferror-limit 19 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fgnuc-version=4.2.1 -fmax-type-align=16 -fcolor-diagnostics -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /var/folders/qz/b881qqrj15s4ftjcv08kdngh0000gn/T/c-7d327c.o -x c c.c
clang -cc1 version 16.0.6 based upon LLVM 16.0.6 default target x86_64-apple-darwin23.2.0
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/local/include"
ignoring nonexistent directory "/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/Library/Frameworks"
#include "..." search starts here:
#include <...> search starts here:
/opt/pkg/lib/clang/16/include
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/usr/include
/Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Frameworks (framework directory)
End of search list.
"/opt/pkg/bin/ld64.lld" -demangle -no_deduplicate -dynamic -arch arm64 -platform_version macos 14.0.0 14.0.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -o a.out /var/folders/qz/b881qqrj15s4ftjcv08kdngh0000gn/T/c-7d327c.o -lSystem
$ file a.out
a.out: Mach-O 64-bit executable arm64
$ ./a.out
hi
Hey,
Really appreciate the work you do.
Ive been trying to get clang to work on macos on and off a ton of times. Is there anyone using the binary packages for clang on macos as main compiler? (meaning replacing the xcode's clang) What options have you set to get it to work!? Installed from : https://pkgsrc.joyent.com/install-on-macos/
Ofcource adding /opt/pkg/bin first in
PATH
after adding a symlink told -> lld
in /opt/pkg/bin (otherwise it would try to use /usr/bin/ld)If i'd add a printf("hi\n"); i get this:
This is the errors i get (added macos sdk include to try to get rid of the printf error above):
$ PATH=/opt/pkg/bin:$PATH LDFLAGS="-L/opt/pkg/lib -Wl,-rpath,/opt/pkg/lib" CPPFLAG="-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/ -I/opt/pkg/include -I/opt/pkg/include/c++/v1/" /opt/pkg/bin/clang -Wimplicit-function-declaration -v c.c
I have seen this question asked around, could be good to add to a documentation Thanks in advance.