diorcety / crosstool-ng

crosstool-ng fork with the full support of Darwin/Linux/Windows as build and host machine
Other
33 stars 15 forks source link

apple-darwin10 target: linker fails #17

Closed kyleconroy closed 10 years ago

kyleconroy commented 10 years ago

I'm attempting to use the x64_64-apple-darwin10 toolchain to cross compile Go programs that utilize cgo (the official bridge between C code and Go code).

I've built the x86_64-apple-darwin10 toolchain on Ubuntu 12.04, building crosstool-ng from source.

$ ./ct-ng x86_64-apple-darwin10
$ ./ct-ng build

I'm attempting to build a very simple cgo program, echocgo, which just prints out command line arguments.

I'm compiling the program with the following command

CC=x86_64-build_unknown-linux-gnu-gcc GOOS=darwin GOARCH=amd64 CGO_ENABLED=1 go build -x -ldflags="-extld=x86_64-build_unknown-linux-gnu-gcc"

I'm not sure why the name of the apple-darwin toolchain is x86_64-build_unknown-linux-gnu-gcc. Anyways, the above command eventually calls out to the linker here:

x86_64-build_unknown-linux-gnu-gcc -m64 -gdwarf-2 -Wl,-no_pie,-pagezero_size,4000000 -o cgoecho output/000000.o output/000001.o output/go.o -lpthread

This fails with the error

/usr/bin/ld: unrecognized option '-pagezero_size'

So I'm wondering two things: is the toolchain using the correct linker? And secondly, why that flag doesn't work using the apple-darwin10 toolchain. Thanks for reading this long and rambling bug report.

kyleconroy commented 10 years ago

The pagezero_size flag exists when using ld64 on OSX. Am I using crosstool-ng correctly? I'm not sure why the toolchain I built isn't using ld64.

mingwandroid commented 10 years ago

CC=x86_64-build_unknown-linux-gnu-gcc is wrong. CC=x86_64-apple-darwin10-gcc is better, x86_64-apple-darwin10-clang is even better.

On Fri, Mar 14, 2014 at 2:38 AM, Kyle Conroy notifications@github.comwrote:

The pagezero_size flag exists when using ld64 on OSX. Am I using crosstool-ng correctly? I'm not sure why the toolchain I build isn't using ld64.

Reply to this email directly or view it on GitHubhttps://github.com/diorcety/crosstool-ng/issues/17#issuecomment-37610608 .

kyleconroy commented 10 years ago

Thanks, I somehow missed the ~/x-tools directory, where all the needed compilers ended up. Thanks for the help!