plentico / osxcross-target

Provides darwin (Mac) binary support on Linux when cross-compiling Go apps that have CGO dependencies
16 stars 0 forks source link

unrecognised emulation mode: llvm #6

Closed jimafisk closed 2 weeks ago

jimafisk commented 2 weeks ago

When implementing the Ubuntu 24.04 upgrade, after creating my osxcross target, using it to build the Plenti binary like: env GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 CC=/home/runner/work/osxcross/target/bin/o64-clang CXX=/home/runner/work/osxcross/target/bin/o64-clang++ go build -ldflags -s

Would throw:

# rogchap.com/v8go
v8go.cc:500:24: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
v8go.cc:500:24: note: read of non-const variable 'args_count' is not allowed in a constant expression
v8go.cc:499:7: note: declared here
v8go.cc:1611:21: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
v8go.cc:1611:21: note: function parameter 'argc' with unknown value cannot be used in a constant expression
v8go.cc:1606:56: note: declared here
v8go.cc:1634:21: warning: variable length arrays in C++ are a Clang extension [-Wvla-cxx-extension]
v8go.cc:1634:21: note: function parameter 'argc' with unknown value cannot be used in a constant expression
v8go.cc:1630:48: note: declared here
# github.com/plentico/plenti
/usr/local/go/pkg/tool/linux_amd64/link: running /home/runner/work/osxcross/target/bin/o64-clang++ failed: exit status 1
/home/runner/work/osxcross/target/bin/o64-clang++ -arch x86_64 -m64 -Wl,-S -Wl,-x -o $WORK/b001/exe/a.out /tmp/go-link-180839997/go.o /tmp/go-link-180839997/000000.o /tmp/go-link-180839997/000001.o /tmp/go-link-180839997/000002.o /tmp/go-link-180839997/000003.o /tmp/go-link-180839997/000004.o /tmp/go-link-180839997/000005.o /tmp/go-link-180839997/000006.o /tmp/go-link-180839997/000007.o /tmp/go-link-180839997/000008.o /tmp/go-link-180839997/000009.o /tmp/go-link-180839997/000010.o /tmp/go-link-180839997/000011.o /tmp/go-link-180839997/000012.o /tmp/go-link-180839997/000013.o /tmp/go-link-180839997/000014.o /tmp/go-link-180839997/000015.o /tmp/go-link-180839997/000016.o /tmp/go-link-180839997/000017.o /tmp/go-link-180839997/000018.o /tmp/go-link-180839997/000019.o /tmp/go-link-180839997/000020.o /tmp/go-link-180839997/000021.o /tmp/go-link-180839997/000022.o /tmp/go-link-180839997/000023.o /tmp/go-link-180839997/000024.o /tmp/go-link-180839997/000025.o /tmp/go-link-180839997/000026.o /tmp/go-link-180839997/000027.o /tmp/go-link-180839997/000028.o -lresolv -O2 -g -pthread -lv8 -L/home/jim/go/pkg/mod/rogchap.com/v8go@v0.8.0/deps/darwin_x86_64 -O2 -g -lpthread -framework CoreFoundation -framework Security
/usr/bin/ld: unrecognised emulation mode: llvm
Supported emulations: elf_x86_64 elf32_x86_64 elf_i386 elf_iamcu i386pep i386pe
clang++: error: linker command failed with exit code 1 (use -v to see invocation)

I thought this might have been because I initially created my "build" assets in ~/Downloads then later transferred it to /home/runner/work/osxcross/build so it would be in the right place for this project. I removed the build folder (rm -R build) and re-ran ./tools/gen_sdk_package_pbzx.sh Xcode_16.1.xip to recreate it and then reran ./build.sh but still have the same issue. I've also added sudo apt-get install build-essential per https://github.com/plentico/plenti/issues/348.

jimafisk commented 2 weeks ago

In doing some research, it seemed like the problem is the system /usr/bin/ld is being used instead the target's: https://stackoverflow.com/questions/54406361/ld-unrecognised-emulation-mode-aarch64linux/59051498

Running the following in my terminal per https://github.com/tpoechtrager/osxcross/issues/420 seems to have fixed this issue:

export PATH=/home/runner/work/osxcross/target/bin:$PATH