Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build compiler on mingw #1540

Closed
emekoi opened this issue Sep 17, 2018 · 18 comments
Closed

build compiler on mingw #1540

emekoi opened this issue Sep 17, 2018 · 18 comments
Milestone

Comments

@emekoi
Copy link
Contributor

emekoi commented Sep 17, 2018

is zig tested regularly on mingw(-w64), or is it known to compile successfully there?

@andrewrk andrewrk added this to the 1.0.0 milestone Sep 17, 2018
@andrewrk
Copy link
Member

We used to test building for mingw in the CI, but the mingw llvm packages were outdated for too long, and I was unable to build LLVM and libclang from source with mingw. This will eventually be solved by #853

@emekoi
Copy link
Contributor Author

emekoi commented Sep 17, 2018

i've gotten it to compile but is doesn't work in the console (exits with exit code 127) or gdb (exits with error code 0xc0000139 before main is even run); however it will open in cmd and git bash but it will segfault when i try to run the tests or compile anything.

@andrewrk
Copy link
Member

andrewrk commented Sep 17, 2018

Yeah. At this point, only builds with msvc are supported. It would be nice to add mingw support before #853 is solved, but it was too hard to test, since the packages didn't have the latest llvm version, and building llvm from source didn't work.

We're about to depend on LLVM 7.0.0 which is scheduled to be released this week. I'm guessing those packages won't be available in mingw for several months.

@ghost
Copy link

ghost commented Sep 17, 2018

if building llvm with mingw did not work because of timeouts we could fix this with
#835 (comment) , if its because of some other issue then this would not help obviously (quick closed-issue search did not reveal anything).

@emekoi
Copy link
Contributor Author

emekoi commented Sep 17, 2018

huzzah! the problem was that zig was loading the wrong dll (dlls from qemu) instead of the ones from mingw. now i can work on that segfault...

@emekoi
Copy link
Contributor Author

emekoi commented Sep 17, 2018

ok this is weird but the first time i run the compiler it segfaults but after that it starts giving proper error messages, then it will repeat this every time it gets further than it did last time.

@andrewrk
Copy link
Member

I wonder if that's trying to compute the compiler id. Try wiping ~/.local/share/zig/stage1/ and then running zig id.

@emekoi
Copy link
Contributor Author

emekoi commented Sep 17, 2018

that worked but now i have to rebuild because of reasons.

@emekoi
Copy link
Contributor Author

emekoi commented Sep 17, 2018

it works!!! now i just need to run the test suite....
which tests depend on linking to libc? because linking to libc isn't supported yet.

@andrewrk
Copy link
Member

which tests depend on linking to libc?

Here's an example to test libc detection:

$ ./zig build-exe ../example/hello_world/hello_libc.zig --library c
$ ./hello
Hello, world!

@emekoi
Copy link
Contributor Author

emekoi commented Sep 18, 2018

no i mean which don't link to libc. as zig is now it doesn't support linking to libc on mingw so i can't run these tests. or is there a way to keep the test harness running if some tests fail?

@andrewrk
Copy link
Member

andrewrk commented Sep 18, 2018

./zig test ../test/behavior.zig
./zig test ../std/index.zig

That covers most stuff without depending on libc. We could also add a flag to the main test command that would exclude libc stuff.

@emekoi
Copy link
Contributor Author

emekoi commented Sep 22, 2018

does zig need to link to compiler-rt? or does it only link to libLLVM, libclang, and libLDD?

@emekoi emekoi reopened this Sep 22, 2018
@andrewrk
Copy link
Member

It only links to libLLVM and libclang.

LDD is source-embedded in zig and compiler rt is built lazily from zig source for the target.

@emekoi
Copy link
Contributor Author

emekoi commented Sep 22, 2018

so i don't need libssp, libcxx, etc.?

@andrewrk
Copy link
Member

I'd be happy to look at a paste of errors that you're getting if you're having trouble. Zig only depends on a c++ compiler, libclang, and libllvm.

@emekoi
Copy link
Contributor Author

emekoi commented Sep 22, 2018

it's not that i'm getting errors building zig, it's that i;m building the llvm 7 tool chain from scratch so i can use the most recent version on zig. i was having problems with getting compiler-rt to compile so i thought it best to ask if was actually needed.

@emekoi emekoi closed this as completed Sep 22, 2018
@emekoi emekoi reopened this Sep 25, 2018
@emekoi
Copy link
Contributor Author

emekoi commented Sep 25, 2018

currently, elf format is chosen as the default on mingw if you built llvm from source. is there a way to change the default target?
EDIT: i think i narrowed the error down to how llvm parses target triples.

@emekoi emekoi closed this as completed Sep 30, 2018
@andrewrk andrewrk modified the milestones: 1.0.0, 0.4.0 Apr 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants