zigler icon indicating copy to clipboard operation
zigler copied to clipboard

llvm error when compiling nif library in windows

Open ityonemo opened this issue 4 years ago • 4 comments

@seomwan encountered this error when trying to build the nif library on windows

Currently stuck at LLVM ERROR: Bad $ operand number: #195 (comment)

LLVM ERROR: Bad $ operand number in inline asm string:

possibly a missing configuration setting when compiling for windows in general, might require

  • changes to build.zig that depend on windows

ityonemo avatar Dec 19 '20 23:12 ityonemo

Some more details:

I used this mix test command to reproduce (hope it's doing what I think it is and just running that test only):

mix test .\test\support\zigtest\failing_test.ex

The output is this:

[..]
Compiling test/support/zigtest/failing_test.ex (it's taking more than 10s)
Compiling test/support/zigtest/passing_tests.ex (it's taking more than 10s)

== Compilation error in file test/support/zigtest/failing_test.ex ==
** (CompileError)  this zig compiler warning hasn't been incorporated into the parser.
Please file a report at:
https://github.com/ityonemo/zigler/issues
<--- missing zig error message details in this line HERE <--- 

    lib/zig/parser/error.ex:54: Zig.Parser.Error.parse/2
    lib/zig/command.ex:36: Zig.Command.compile/2
[..]

Noticed three things:

  1. ex file compilation timing messages (it's taking more than 10s) at the beginning
  2. missing zig error message details (as indicated by in this line HERE <--- )
  3. it's compiling other tests while only failing_test.ex was given as an argument

Doing it a second time doesn't have that issue, and gives a proper error message:

[..]
== Compilation error in file test/support/zigtest/failing_test.ex ==
** (CompileError)  this zig compiler warning hasn't been incorporated into the parser.
Please file a report at:
https://github.com/ityonemo/zigler/issues
LLVM ERROR: Bad $ operand number in inline asm string: ' movl %fs:0x18, $92135591189151744'

    lib/zig/parser/error.ex:54: Zig.Parser.Error.parse/2
[..]

A third time gives the same error message as expected. But I'd expected the string to change randomly, but it didn't. However, another test was run this time:

== Compilation error in file test/support/zigtest/passing_tests.ex ==

Along with ZiglerTest.ZigTest.Transitive, the three tests are generated every time, although only one test runs and gives the error message.

Why does this happen? Am I using mix test the wrong way to run a single test?

seomwan avatar Dec 21 '20 10:12 seomwan

This issue was recently fixed, it should build just fine now.

LemonBoy avatar Jan 15 '21 11:01 LemonBoy

I think @ityonemo may need to update, they're mostly tracking stable branch?

seomwan avatar Jan 21 '21 20:01 seomwan

Cool. I'm deliberately tracking stable branch on zigler, but it should be possible to tell use Zig to use a custom zig version. I'll try to test it out this weekend to make sure that feature is working, then I can push guidance to the docs on how to use with windows.

ityonemo avatar Jan 21 '21 20:01 ityonemo