odin-lang / Odin

Odin Programming Language
https://odin-lang.org
BSD 3-Clause "New" or "Revised" License
6.55k stars 570 forks source link

Odin fails `brew test` on Big Sur #792

Closed carlocab closed 3 years ago

carlocab commented 3 years ago

Context

brew test odin should succeed.

Current Behavior

brew test odin produces the following error:

Error: odin: failed
An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - ./hellope
[snip]

See https://github.com/Homebrew/homebrew-core/pull/65223#issuecomment-733654271 for details.

Failure Information (for bugs)

Steps to Reproduce

Run the following commands in a terminal.

  1. brew install odin
  2. brew test odin

Failure Logs

test.01.odin.log

❯ brew install odin && brew test odin
==> Downloading https://homebrew.bintray.com/bottles/odin-0.13.0.catalina.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/772509e10bf0a73af78b51e4f85309eb6d25e0078d1f2fa02bfa2d252e0055ca?respons
######################################################################## 100.0%
==> Pouring odin-0.13.0.catalina.bottle.tar.gz
🍺  /usr/local/Cellar/odin/0.13.0: 133 files, 2.6MB
==> Testing odin
==> /usr/local/Cellar/odin/0.13.0/bin/odin version
==> /usr/local/Cellar/odin/0.13.0/bin/odin build hellope.odin
Error: odin: failed
An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - ./hellope
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/odin.rb:49:in ``'
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/odin.rb:49:in `block in <class:Odin>'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1862:in `block (3 levels) in run_test'
/usr/local/Homebrew/Library/Homebrew/utils.rb:500:in `with_env'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1861:in `block (2 levels) in run_test'
/usr/local/Homebrew/Library/Homebrew/formula.rb:900:in `with_logging'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1860:in `block in run_test'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `block in run'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `chdir'
/usr/local/Homebrew/Library/Homebrew/mktemp.rb:63:in `run'
/usr/local/Homebrew/Library/Homebrew/formula.rb:2104:in `mktemp'
/usr/local/Homebrew/Library/Homebrew/formula.rb:1854:in `run_test'
/usr/local/Homebrew/Library/Homebrew/test.rb:43:in `block in <main>'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:93:in `block in timeout'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `block in catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:33:in `catch'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/timeout.rb:108:in `timeout'
/usr/local/Homebrew/Library/Homebrew/test.rb:42:in `<main>'
carlocab commented 3 years ago

For reference, brew test odin attempts to compile the following program:

package main

import "core:fmt"

main :: proc() {
    fmt.println("Hellope!");
}

Compiling this program produces this error:

❯ odin build test.odin
ld: library not found for -lc
gingerBill commented 3 years ago

Odin requires LLVM in order to work and it appears that LLVM is not being installed alongside Odin.

I don't know who has set up the homebrew for Odin.

carlocab commented 3 years ago

Odin declares llvm as a dependency. You don't see it installed in the snippet I shared because I already have it installed and included in my PATH.

❯ brew info odin
odin: stable 0.13.0 (bottled), HEAD
Programming language with focus on simplicity, performance and modern systems
https://odin-lang.org/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/odin.rb
License: BSD-2-Clause
==> Dependencies
Required: llvm ✔
[snip]

If you check the CI tests in the PR I linked, you'll see that brew test odin succeeds on 10.14 and 10.15.

gingerBill commented 3 years ago

Wait a minute... the problem appears to be -lc is missing which should only be called on Linux, not macOS.

carlocab commented 3 years ago

I see. Well, for some reason, it is being called on Big Sur but not on earlier versions of macOS.

Platin21 commented 3 years ago

You can’t add -lc in the macOS big sur version.

gingerBill commented 3 years ago

I don't even see where -lc is being added either.

carlocab commented 3 years ago

You can’t add -lc in the macOS big sur version.

Noted. I didn't add it.

Platin21 commented 3 years ago

It’s bit added for macOS and the main reason is that it doesn’t work. There is no library for that anymore they moved that completely to System. So yeah should not be there and it also seems like it isn’t?

Could be that this doesn’t include the fix? Not sure will look.

Platin21 commented 3 years ago

Yeah it’s not in 13.0 but in current master it is correct. So the question is more when will be a new version released @gingerBill ? Do we wait until we get llvm api working?

carlocab commented 3 years ago

Homebrew can also apply a patch to 13.0 to get it working if the new version isn't going to be released soon. I don't use Odin, however, so it would help if someone here can provide one, ideally hosted on this repo.

The llvm brew formula gives examples of upstream patches that have been applied to the version packaged by Homebrew: https://github.com/Homebrew/homebrew-core/blob/deda5a05551ab74d5313af112d3bb2054f9b6af8/Formula/llvm.rb#L12-L30

Platin21 commented 3 years ago

Thing is the patch would be inside of this repo itself. Just to fix that github changed there default macOS version.

carlocab commented 3 years ago

Yes, I understand that. Is there a specific commit on this repo that can be applied to 13.0?

If not, then, if the patch is small, it can be added directly in the Homebrew formula (the Ruby file that determines how Odin is installed). If it isn't, then I can submit it to Homebrew/formula-patches for hosting until the next version of Odin is released.

Platin21 commented 3 years ago

Should be https://github.com/odin-lang/Odin/commit/81398d21ed25ca50dcfab7b9c7135c33adbb8e34 i think.

carlocab commented 3 years ago

Great, thanks. Let me try and see if that commit will apply.

carlocab commented 3 years ago

Patch doesn't apply cleanly, sadly.

==> Patching
==> Applying 81398d21ed25ca50dcfab7b9c7135c33adbb8e34.patch
patching file src/main.cpp
Hunk #1 FAILED at 431.
Hunk #2 FAILED at 2221.
2 out of 2 hunks FAILED -- saving rejects to file src/main.cpp.rej
patching file src/main.cpp
Hunk #2 succeeded at 2100 (offset -39 lines).
patching file src/main.cpp
Hunk #1 FAILED at 435.
1 out of 1 hunk FAILED -- saving rejects to file src/main.cpp.rej
patching file src/main.cpp
Hunk #2 FAILED at 431.
Hunk #3 succeeded at 2097 (offset -39 lines).
Hunk #4 FAILED at 2181.
2 out of 4 hunks FAILED -- saving rejects to file src/main.cpp.rej
patching file src/main.cpp
Hunk #2 FAILED at 434.
Hunk #3 succeeded at 2100 (offset -39 lines).
Hunk #4 FAILED at 2187.
2 out of 4 hunks FAILED -- saving rejects to file src/main.cpp.rej
patching file src/main.cpp
Hunk #2 FAILED at 431.
Hunk #3 succeeded at 2097 (offset -39 lines).
Hunk #4 FAILED at 2182.
2 out of 4 hunks FAILED -- saving rejects to file src/main.cpp.rej
Platin21 commented 3 years ago

Yeah i almost suspected that because it’s a merge and there where other changes.

carlocab commented 3 years ago

I see.

Well, if you can come up with a single patch that can work (or even a series of commits that will), I'd be happy to fix the brew formula so that it'll work.

Otherwise, I guess brew-packaged Odin may have to wait for the next release to work on Big Sur.

Rylan12 commented 3 years ago

I've opened a PR to backport the patch to work until the next version of odin is released. That should solve the problem.

https://github.com/Homebrew/homebrew-core/pull/66906

carlocab commented 3 years ago

Thanks, @Rylan12!