I'm having trouble getting llvm set up on Windows, getting this error:
error: failed to run custom build command for `llvm-sys v100.2.0`
I've run through the Building from Source guide a few times, building llvm in different ways. Does anyone have some insight on what I need to do to fix this? Thanks!
not a windows user, but this seems like a good windows-specific guide https://github.com/ziglang/zig/wiki/How-to-build-LLVM,-libclang,-and-liblld-from-source#windows if you want to do it from source
@Ian Mackenzie was very helpful in getting me set up!
Got it working and successfully ran the repl!
nice!!!
if you have any edits to the instructions that might help the next person get up and running on Windows, a PR would be great!
Haha, that's the trick. I'm not sure what I was doing wrong. It may be that I was missing the Python or CMake dependencies that I installed while trying the Zig guide that Folkert linked. Ultimately I went through the steps in the Roc guide again with nmake and it worked.
I'll make a PR to add those possible dependencies though.
Oh, you know what, the https://llvm.org/docs/GettingStarted.html guide does list those dependencies further below. I hadn't read the rest of that guide.
I was looking at this section and couldn't find the recommended version to install on Mac OS X https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#llvm
so I'm trying with the latest and greatest. Will report if it works fine or not
What version do you see on brew info llvm
? It might be llvm 11 and I'm confident that version will not work. I'm currently using 10.0.1.
yep, can confirm it doesn't. the readme above suggests using 10.0.0_3 which is what I'm trying
there's still something wrong :(
$ brew info llvm
llvm: stable 10.0.0 (bottled), HEAD [keg-only]
Next-gen compiler infrastructure
https://llvm.org/
/usr/local/Cellar/llvm/10.0.0_3 (7,055 files, 1GB)
Poured from bottle on 2021-03-26 at 12:36:37
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/llvm.rb
==> Dependencies
Build: cmake ✘, python@3.8 ✘
Required: libffi ✔
==> Requirements
Build: Xcode ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
llvm is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
If you need to have llvm first in your PATH, run:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> /Users/arkham/.bash_profile
For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"
==> Analytics
install: 18,593 (30 days), 68,307 (90 days), 234,327 (365 days)
install-on-request: 15,100 (30 days), 54,439 (90 days), 185,622 (365 days)
build-error: 0 (30 days)
and the error I get is:
$ cargo run repl
Compiling roc_builtins v0.1.0 (/Users/arkham/code/roc/compiler/builtins)
Compiling cc v1.0.67
Compiling rand_core v0.6.2
Compiling directories-next v2.0.0
Compiling colored v2.0.0
Compiling dirs-next v2.0.0
Compiling petgraph v0.5.1
Compiling backtrace v0.3.56
Compiling spirv_headers v1.5.0
error: failed to run custom build command for `roc_builtins v0.1.0 (/Users/arkham/code/roc/compiler/builtins)`
Caused by:
process didn't exit successfully: `/Users/arkham/code/roc/target/debug/build/roc_builtins-abe28cf79a8a01a1/build-script-build` (exit code: 101)
--- stdout
Compiling zig object to: /Users/arkham/code/roc/compiler/builtins/bitcode/builtins.o
Moving zig object to: /Users/arkham/code/roc/target/debug/build/roc_builtins-8a0ab0a538352427/out/builtins.o
Compiling ir to: /Users/arkham/code/roc/compiler/builtins/bitcode/builtins.ll
Compiling bitcode to: /Users/arkham/code/roc/target/debug/build/roc_builtins-8a0ab0a538352427/out/builtins.bc
--- stderr
thread 'main' panicked at 'llvm-as-10 failed: No such file or directory (os error 2)', compiler/builtins/build.rs:78:24
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
I've exported LDFLAGS
and CPPFLAGS
as brew suggested
oh, is it because it's trying to run llvm-as-10
, while the locally installed version is just llvm-as
?
yup, that was it :)
Finished dev [unoptimized + debuginfo] target(s) in 2m 18s
Running `target/debug/roc repl`
The rockin' roc repl
────────────────────────
Enter an expression, or :help, or :exit/:q.
» 1 + 100
101 : Num *
oh yeahh
updated instructions here: https://github.com/rtfeldman/roc/pull/1113
:+1: I think the CI error could be because we're not using the latest rust version on CI yet, I'll check it out.
Looks like Richard was already working on it :)
https://github.com/rtfeldman/roc/pull/1112
I am getting errors when building from source. I am on MacOS and I've tried the steps in the troubleshooting section. Can someone help me?
╰─ cargo run repl
Compiling roc_builtins v0.1.0 (/Users/motionstatic/ws/dev/roc/compiler/builtins)
Compiling cgmath v0.18.0
Compiling im-rc v14.3.0
Compiling im v14.3.0
Compiling crossbeam-deque v0.7.3
Compiling im v15.0.0
Compiling im-rc v15.0.0
Compiling thiserror v1.0.24
Compiling rand v0.7.3
Compiling serde v1.0.124
error: failed to run custom build command for roc_builtins v0.1.0 (/Users/motionstatic/ws/dev/roc/compiler/builtins)
Caused by:
process didn't exit successfully: /Users/motionstatic/ws/dev/roc/target/debug/build/roc_builtins-7f77b815e7e30688/build-script-build
(exit code: 101)
--- stdout
Compiling zig object to: /Users/motionstatic/ws/dev/roc/compiler/builtins/bitcode/builtins.o
--- stderr
thread 'main' panicked at 'zig failed: Unable to create builtin.zig: file not found
', compiler/builtins/build.rs:75:17
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
Do you have Zig installed?
Zeljko Nesic said:
Do you have Zig installed?
Yes.
─ zig version = 0.6.0
I used brew install zig
Hi Peter, we're currently using zig 0.7.1, I'll make sure to add that to the zig section of BUILDING_FROM_SOURCE.
apparently the install instructions give you llvm 11 now on macos at least. Can we find instructions to get a specific version?
we use llvm 10 for the moment; also need to upgrade that at some point but that'll cause a bunch of breakage/frustration probably
I've recently updated the instructions for mac os! https://github.com/rtfeldman/roc/blob/trunk/BUILDING_FROM_SOURCE.md#llvm-installation-on-macos
ah, excellent, @Peter Fields maybe the updated version gives better results
@Peter Fields pre-built binaries also work well but it's not as elegant
Inkwell supports LLVM 11 now, so in theory we could update our fork to take advantage of that
So it's like 6 hours later and the nix build still seems to be going... is this normal? :thinking:
Seems to have selected an awfully large number of packages which appear to all be building from scratch?
kind of, LLVM takes super super long to build. depends on how much power your machine has, so hard to say if 6hrs itself is normal
I'm going throw the pain now cause I just switched to linux, also I think the nix setup is broken at the moment
Seems it's given up here:
trying https://ziglang.org/builds/zig-macos-x86_64-0.7.1.tar.xz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
curl: (22) The requested URL returned error: 403
error: cannot download zig-macos-x86_64-0.7.1.tar.xz from any mirror
builder for '/nix/store/m4a7fps28v1qh7v12dyfgx96899j7h97-zig-macos-x86_64-0.7.1.tar.xz.drv' failed with exit code 1
building '/nix/store/zmlxwgfzagln7yqg14c00g6xd0mq1gjj-python-2.7.18.drv'...
cannot build derivation '/nix/store/2y7qyxdlgg9qmbwcclylmd9myqac4c2a-zig-0.7.1.drv': 1 dependencies couldn't be built
oofff. for macOS I just downloaded a pre-built llvm and mapped some ENV vars myself
the error that made think nix was messed up is happening to me without nix, so forget what I said
@Mario great to see you! :wave:
I think you might be the first one to try building Roc on M1 hardware, so I have no idea what to expect there, on Nix or otherwise :laughing:
I think @Brendan Hansknecht has built it successfully on a Raspberry Pi though, which also runs on ARM, but that was awhile ago and I don't think it was on Nix :thinking:
cannot download zig-macos-x86_64-0.7.1.tar.xz
seems like it's missing from the Nix store - Roc's standard library is written in https://ziglang.org/ so the zig
executable needs to be on your PATH
to build Roc - I forget if there's a way to add mirrors to Nix derivations, but the file it's looking for is hosted here on the Zig website: https://ziglang.org/download/0.7.1/zig-macos-x86_64-0.7.1.tar.xz
ha, perfect timing - here's a fix for Nix on aarch64! https://github.com/rtfeldman/roc/pull/1198#issuecomment-820021740
cc @Mario
I just got everything working really smooth on fedora
Richard Feldman said:
I think you might be the first one to try building Roc on M1 hardware, so I have no idea what to expect there, on Nix or otherwise :laughing:
Awesome! :tada: Continuing the build... will report back... eventually? :D
I'm _kind of_ making progress on the M1 nix build! I've started a PR with details here: any help/tips appreciated! https://github.com/rtfeldman/roc/pull/1204
I'm struggling to get anywhere on macOS, I've been trying since yesterday to get llvm installed. Not really sure which direction I need to be going in. Some things I have tried:
So I'm not really sure what my next step here is. Am I missing something obvious, or do I need to set up a Linux environment?
@Tarjei Skjærset on macos I never managed to even build LLVM from source, not even with llvmenv
(which is what I use on linux)
I recommend two options:
1) use nix and nix-shell which should be working
2) download a pre-built llvm for macos and add this function to your .bashrc/.zshrc
llvminit() {
export LLVM_SYS_100_PREFIX=$HOME/Downloads/llvm
export PATH=$PATH:$HOME/PATH_TO_ROC_REPO/nix/bin:$HOME/Downloads/llvm:$HOME/Downloads/llvm/bin
}
then everytime I start a new terminal session and switch to the roc folder I run llvminit
first and everything should work
make sure your Rust version is up to date as well
I'm happy to jump on a call and get you started let me know
Is the nix-shell supposed to be working without llvm explicitly installed? I tried running cargo run repl
earlier, but assumed the reason it didn't work was because I hadn't gotten the llvm installation working. As for 2), I'm guessing that's essentially what I was doing when I tried downloading the binaries, but the issue I ran into there was with macOS' security model where it just won't run stuff unless you allow it in the privacy & security thingy - which I tried, but there are just so many executables.
What Rust version am I supposed to be on, and how do I check?
nix shell pulls llvm for you so yes
it could be that the nix setup on mac is broken, it didn't work for me over a month ago suddenly and I gave up on it
Ohh okay, well I'm happy to rely on nix-shell (although hadn't heard about it before), so that's a separate problem then
so to allow the binaries to run, you just quickly open system preferences and hit allow
it should show up in the Security & Privacy section of system preferences after you try to run it the first time
Yeah I did try that , but there were literally tens of them. I didn't get it to work, so I scrapped it and tried other stuff, but I'm happy to try that again. Give me a second to uninstall everything else, and I'll give the prebuilt binaries a go again
oh I see gotcha, I was only prompted for like 2 of them, I wonder if you can enable them via the CLI and do it all in one go
for the rust version, you probably have rustup installed (hopefully), so just rustup update and you're good
to check versions you can do rustup show
I'm here all day so just ping here again with an update
So have you just left your llvm binaries in your Downloads folder? I tried copying them around to where I thought they were supposed to go, but I was doing that blind.
I left it in downloads, :shrug:
Ah, rustup says rustc 1.52.1
and I only bring them into the path when in the roc folder via the llvminit
function
cause mac has it's own version anyways
it's just newer than the one we need for inkwell
you might have luck with llvmenv
oh actually no, it has no clue where -lSystem
is on Big Sur
Okay that's fine by me. Is it just supposed to work now?
you got llvm locally ?
and everything in your path?
try cargo run repl
and see what happens
Seems to be compiling fine when I run cargo run repl
in regular zsh. Maybe I got tripped up trying to run nix-shell yesterday and thought the llvm binaries weren't working.
perfect
if LLVM_AS_SYS doesn't scream right away you're in the clear I think
It's still going! How long is it supposed to take? Are there incremental builds?
fresh one will take a few seconds maybe a minute, not sure what your specs are but the rust compiler is just slower on mac in general from what I noticed
incremental builds, not sure, whatever rust does
I think because we have a mono repo of crates yes
I got a repl! Man, so excited
Well it crashed
for sure probably Security?
But that's progress, thanks man!
was it a linker error?
Yeah, ld: framework not found Security
you can just comment out the -framework Security thing in link.rs
or linking.rs
just global search the project for Security
and comment out that and the line above it
it's mostly just for running a single example and won't be there long term anyways
I do that everytime if I'm on mac lol
Oh god
link.rs line 469 & 470
Yeah I found it! I just worried about the thought of doing that every time I pull trunk
it's fine, you can probably figure out how to make that framework available
I just didn't care
Heey there we go, my first Roc expression! image.png
List.map [ 1, 2, 3, 4 ] \x -> x + 1
Thanks so much for the help! I'll play around for a bit, but I would really love to pair some time :smiley:
I'm good any day and in Miami, FL usually awake by 7-9AM
yeah, you can see why we're all about the "not ready for a release yet!" in how we talk about Roc publicly :joy:
long-term goal is that there's a single roc
executable to download and that's it - it has the editor, no external libraries to install, etc
but that will take some doing :big_smile:
thanks for being patient with it, and thanks @Lucas Rosa for helping out!
Following https://github.com/rtfeldman/roc/issues/1418, I still get the error using nix installation. examples/hello-world/hello-world: symbol lookup error: /nix/store/sbbifs2ykc05inws26203h0xwcadnf0l-glibc-2.32-46/lib/libc.so.6: undefined symbol: _dl_fatal_printf, version GLIBC_PRIVATE
:sweat_smile:
hm, any ideas @Jared Ramirez? :thinking:
I'm not sure. I just ran cargo run run examples/hello-world/Hello.roc
on the latest trunk
on macos with everything installed via nix and it worked for me. My guess is that there's a difference on Ubuntu
@Chen Yu one alternate idea is to run the manual instructions in BUILDING_FROM_SOURCE.md
- both @Folkert de Vries and I run that setup on Ubuntu without Nix, and it's entirely possible that currently there's nobody else trying to build Roc from Nix on Ubuntu :sweat_smile:
OK, thanks~ If I figure it out I will inform you folks~
I build from source on fedora without nix using llvmenv to manage multiple llvm versions, feel free to bother me as well
Sorry for the silly questions - is it possible to output wasm somehow?
I think LLVM can yes
but not sure anyone has bothered yet
well in theory we allow 32-bit pointers but nobody has tested that yet
Which command would I need to run
I am not very experienced with this lower-level deelopment
so everything is built to allow it, but it's untested
hmm, no idea actually
I’m not sure there is one single command at the moment
might have to dig in the code and pass some flags to LLVM at code gen?
my assumption is that you'd need to get a hold of the LLVM IR (this is not hard, but not exposed in a friendly way) and then convert that to wasm
Ah I see
but also you'd need to then also compile the host to wasm, and then link stuff together
and we have some external dependencies too right now
so, yea, it's not easy, might not totally work, but things are in place to make it possible at some point
I see that there is compiler/build/src/target and there is a lot of llvm going on :D
https://gist.github.com/yurydelendik/4eeff8248aeb14ce763e
seems informative
meh nvm, not so much, forget that link lol
there sure is a lot of llvm going on. Now in theory we could also directly emit wasm bytecode
for debug builds
I was hoping maybe I can convert the dylib C code to wasm but that seems to not be the right way to go. Again I have next to no experience with compilers. I only compiled my beloved kakoune from source and managed to compile roc now, but I'm more an end-user than a direct user.
because LLVM is slow
may I suggest zig to import the C source an emit wasm?
How would emitting wasm bytecode hook into the compiler arch?
I'm going to take a look at zig.
not sure what dylib you mean btw, but in general if you have C code and want wasm then I think zig is basicallythe easiest approach
we already have gen_llvm
and gen_dev
we could quite easily have a gen_wasm
it takes our intermediate representation and emits the bytecode
I mean there's more to it than that, but at a high level
I mean the dylib I can compile to with the --lib option. But that's not C code I just saw.
Yea using zig to build C code and cross compiling to wasm is smooth
gen_wasm :drooling:
one day for sure
Do you have a good starting point to read about how to build a compiler?
not really, interestingly. It's such a broad topic, and there is a lot of space between "technically working" and what you should do if you write a real production-grade compiler
but in general, there are 4 big phases: parsing, canonicalization (make sure names are defined and such), type checking, and code generation
in practice there is also optimization as a part of code gen
So the gen_wasm is only the last step, right? Are there guides on generator design? Or is it essentially learning how wasm bytecode works and then building a big ol module that outputs it with whatever means necessary?
@Jan Wirth are you interested in working on adding wasm generation support to the Roc compiler? if so, I'd be happy to help via pair programming and such!
yes it's only the last step
we do a lot of collaboration that way around here :big_smile:
idem on the pairing btw
idem? :thinking:
it should mean "the same" or "likewise" in latin?
I would be very pleased to do that but I would need to carve out some time / energy.
oh! TIL :big_smile:
and yea it's in essence converting our intermediate representation to the right sequence of wasm bytecode instructions
@Jan Wirth cool! No pressure or anything, but feel free to hit me up anytime if you decide you want to dive into it!
but there are some design issues there with regards to how we use external code
for sure
e.g. the host or some libc bits that we use
I go on vacay in a week because I really need it and then I think I can decide if I can take it on and to what extend. I have an elm frontend to ship :)
cool cool! :thumbs_up:
enjoy the vacation! :smiley:
so that makes me think maybe taking the LLVM IR we already make and try to turn that into a working wasm app may be an easier starting point
could be, yeah
as a proof of concept
I'm happy and keen to put some stuff on my kindle though, so if you have a nice guide to pair-programming or compilers etc. please share :)
idem - as the first part of idempotence :)
not very kindle-friendly but I think elm's compiler source code is kind of the best thing to read (if you appreciate haskell, of course)
I was already planning to write some Str
docs today, so I'll see about adding some overall compiler docs in there
We would be targeting wat rather than wasm right?
I think wasm bytecode would break my brain :joy:
for speed you should really target the bytecode
but you can always decompile that right to the text-based representation
also doing the text-based one first is totally an option
just to build up the experience of what the WASM format looks like
@Jan Wirth the craftinginterpreters.com book is awesome, new, and beginner friendly. There is a web version available for free
I'd imagine that also does a bunch with bytecode ?
so part 2 is a tree walk interpreter and just traverses the AST for evaluation. Part 3 he redoes everything in C, makes a VM, bytecode from AST, and even a GC
Part 2 is in Java but I’ve been translating it to rust as I go. Part 3 will be in zig for me
oh and this new video is fun: https://youtu.be/Zkd3mZYOOvw
JT worked on typescript, currently does nushell, and was on the same episode of zig showtime as me :D
I just pulled the latest trunk and cargo build
is throwing an error. Looks like a new package got added maybe? Anyone know how to fix it? I'm pretty new to Rust so it's probably something silly.
error: failed to run custom build command for `alsa-sys v0.3.1`
thread 'main' panicked at 'Failed to run `"pkg-config" "--libs" "--cflags" "alsa"`: No such file or directory (os error 2)', /home/brian/.cargo/registry/src/github.com-1ecc6299db9ec823/alsa-sys-0.3.1/build.rs:13:18
if you're on Linux, the mention of alsa
might mean it's related to audio - which we recently introduced to the editor
specifically the error seems to be coming from this crate: https://github.com/diwic/alsa-sys
it looks like the alsa-sys crate is using pkg-config to build something when the crate gets installed, but it's missing something
oh I bet it's this: https://github.com/diwic/alsa-sys/issues/9
so maybe you need to have pkg-config installed? (And if so, maybe we need to add that to the building from source instructions)
Aha! sudo apt-get install pkg-config
seems to have solved it. Thanks Richard!
I added pkg-config
to building from source. I think I'll make a script to install everything required to build from source starting with Ubuntu/Debian.
Trying to build locally for the first time on WSL and getting
> cargo run repl
Compiling roc_builtins v0.1.0 (/home/wolfadex/Development/roc/compiler/builtins)
Compiling pulldown-cmark v0.8.0
Compiling nix v0.17.0
Compiling dlib v0.5.0
Compiling ash v0.33.3+1.2.191
Compiling dlib v0.4.2
Compiling libc v0.2.101
Compiling proc-macro2 v1.0.29
error: failed to run custom build command for `roc_builtins v0.1.0 (/home/wolfadex/Development/roc/compiler/builtins)`
Caused by:
process didn't exit successfully: `/home/wolfadex/Development/roc/target/debug/build/roc_builtins-9e4973e4a864c4ee/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rustc-env=BUILTINS_O=/home/wolfadex/Development/roc/target/debug/build/roc_builtins-00366df05b0327aa/out/builtins.o
Compiling zig object to: /home/wolfadex/Development/roc/compiler/builtins/bitcode/builtins-host.o
--- stderr
thread 'main' panicked at 'zig failed: error: unable to find zig installation directory: FileNotFound
', compiler/builtins/build.rs:124:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
Seems to be something Zig specific. Dug a little and saw that it's trying to do a zig build ...
from /compiler/builtins
and notice that if I run zig build
I get the same error
> zig build
error: unable to find zig installation directory: FileNotFound
Wanted to see if anyone had seen similar before I go digging more
how did you install zig?
It might not know where the source for zig std is
I don't actually remember because I installed it many, many months ago. I'll try re-installing though, thanks!
Thank you! That got me further
no problem
Hi all, silly question :)
when I run cargo build --release
, should I see a roc CLI binary in ./target/release
?
I can see roc
, but that's the editor right?
I was imagining I would build a binary executable and then add it to my PATH so that I can use roc in any arbitrary directory. :sweat_smile:
If you use roc without any arguments, it opens the editor. You can also doroc repl
, roc FILENAME
or roc --help
.
ohhh! that makes a lot of sense. Thank you!
Nathan Kramer has marked this topic as resolved.
> cargo run --release examples/hello-world/Hello.roc
Finished release [optimized] target(s) in 0.23s
Running `target/release/roc examples/hello-world/Hello.roc`
fish: Job 1, 'cargo run --release examples/he…' terminated by signal SIGILL (Illegal instruction)
I can't run any example code
What system are you running on? Also, if you run cargo test
, which ones pass/fail?
running 22 tests
test cli_run::effect ... FAILED
test cli_run::closure ... FAILED
test cli_run::cli ... FAILED
test cli_run::hello_web ... ok
test cli_run::fib ... FAILED
test cli_run::cfold ... FAILED
test cli_run::hello_rust ... FAILED
test cli_run::astar ... FAILED
test cli_run::quicksort_app ... ok
test cli_run::hello_world ... FAILED
test cli_run::hello_zig ... FAILED
test cli_run::quicksort ... FAILED
test cli_run::run_multi_dep_str_optimized ... FAILED
test cli_run::nqueens ... FAILED
test cli_run::base64 ... FAILED
test cli_run::rbtree_insert ... FAILED
test cli_run::rbtree_ck ... FAILED
test cli_run::run_multi_dep_str_unoptimized ... FAILED
test cli_run::run_multi_dep_thunk_optimized ... FAILED
test cli_run::run_multi_dep_thunk_unoptimized ... FAILED
test cli_run::deriv ... FAILED
test cli_run::false_interpreter ... FAILED
Linux
is this still with zig 9? because that just does not work
the llvm versions are not compatible
zig 0.8
interesting. does cargo run -- build --release examples/hello-world/Hello.roc
work?
that just makes the executable, but does not yet run it
No
Thread 1 "roc" received signal SIGILL, Illegal instruction.
<some location> in llvm::getTimeTraceProfilerInstance() ()
from gdb
That just seem like LLVM's fault
which llvm version do you have?
12.0.1-4
is there a way to build within a container with all the dependencies required?
there is a nix recipe, and also our CI script is like a container specification
my guess would be that llvm 12.0.1 is not fully compatible with llvm 12.0
will check out tomorrow
@Locria Cyber if you want to try running roc, there is a nightly release available from a couple of days ago here. If you want to change any source code there is a developer_install.sh script(Debian/Ubuntu) that I still need to double check but should work as is. I also made you a docker container, I'll post a link when it is finished uploading. If you want to use nix, make sure to apply matthiasbeyer's fix, see PR #1831.
@Anton omg I did not know this was an option to use roc like that without all the install steps!
It's a very recent addition :) I was planning on adding it to the docs once the release runs automatically every night, which should be soon.
@Anton speaking of docs. If I want to see the docs do I need to run cargo run docs
?
Coz I tried that and got this on the latest master branch:
oliverschoning@pop-os:~/Projects/roc$ cargo run docs
Finished dev [unoptimized + debuginfo] target(s) in 0.18s
Running `target/debug/roc docs`
── FILE NOT FOUND ──────────────────────────────────────────────────────────────
I am looking for this file, but it's not there:
./compiler/load/tests/fixtures/build/no_deps/ThisFileIsMissing.roc
Is the file supposed to be there? Maybe there is a typo in the file
name?
thread 'main' panicked at 'explicit panic', docs/src/lib.rs:436:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I dunno what "Docs" entails tbh. So far I am just looking at the examples folder and trying to see if I can manage to build something myself :big_smile:
With docs I was referring to the repo README.
I suppose for making or changing examples, it is best to use these resources:
Ok thanks!
cargo run docs
generates documentation for roc files/projects, we're still working on docs syntax highlighting so I'm not sure how much the cargo run docs
command does yet.
Ok, yeah I have never been this early to a project I suppose :smiley:
Anton said:
Locria Cyber if you want to try running roc, there is a nightly release available from a couple of days ago here. If you want to change any source code there is a developer_install.sh script(Debian/Ubuntu) that I still need to double check but should work as is. I also made you a docker container, I'll post a link when it is finished uploading. If you want to use nix, make sure to apply matthiasbeyer's fix, see PR #1831.
Can't use nightly release because of https://github.com/rtfeldman/roc/issues/1811
Can you try using the --roc-linker
flag if you are on Linux?
Hopefully this is the right forum for this, if not please advise!
I'm trying to build from source on macOS Big Sur (11.6) and getting an error about llvm:
I installed llvm
with brew install llvm@12
and then added /usr/local/opt/llvm/bin
to my path, but noticed that no path by that name exists on my system, but /usr/local/opt/llvm@12/bin
does, so I added that to my path and afterwards running llc --version
generates output starting with Homebrew LLVM version 12.0.1
as BUILDING_FROM_SOURCE.md
mentions.
Here's the output I get from running cargo run repl
:
cargo run repl
Compiling llvm-sys v120.2.1
Compiling snafu v0.6.10
Compiling parking_lot_core v0.8.5
Compiling wasmer-vm v2.0.0
Compiling wasmer-wasi-types v2.0.0
Compiling cranelift-frontend v0.74.0
Compiling rodio v0.14.0
error: No suitable version of LLVM was found system-wide or pointed
to by LLVM_SYS_120_PREFIX.
Consider using `llvmenv` to compile an appropriate copy of LLVM, and
refer to the llvm-sys documentation for more information.
llvm-sys: https://crates.io/crates/llvm-sys
llvmenv: https://crates.io/crates/llvmenv
--> /Users/llowder/.cargo/registry/src/github.com-1ecc6299db9ec823/llvm-sys-120.2.1/src/lib.rs:486:1
|
486 | / std::compile_error!(concat!(
487 | | "No suitable version of LLVM was found system-wide or pointed
488 | | to by LLVM_SYS_",
489 | | env!("CARGO_PKG_VERSION_MAJOR"),
... |
496 | | llvmenv: https://crates.io/crates/llvmenv"
497 | | ));
| |___^
error: could not compile `llvm-sys` due to previous error
warning: build failed, waiting for other jobs to finish...
error: build failed
Went ahead and opened an issue for posterity: https://github.com/rtfeldman/roc/issues/1843
you can set that environment variable explicitly, I have this in
set -x LLVM_SYS_120_PREFIX "/home/folkertdev/Downloads/clang+llvm-12.0.0-x86_64-linux-gnu-ubuntu-20.04"
the fish shell equivalent of .bashrc
Thanks! Let me noodle on this see if I can get it working
Hmm wondering where I can find the path of that file on my system :thinking:
it might be easier to install Nix and do things that way :sweat_smile:
ha maybe I should
I think I was over thinking it! export LLVM_SYS_120_PREFIX=/usr/local/opt/llvm@12
seems to make it happier
I was thinking the prefix was supposed to be a specific executable rather than the dir where llvm lives
The rockin’ roc repl
HUZZAH
Perhaps I should open a PR to update BUILDING_FROM_SOURCE.md
awesome, please do! :tada:
https://github.com/rtfeldman/roc/pull/1850
I tried to use Nix for building Roc.
thread 'main' panicked at 'Request adapter', editor/src/editor/main.rs:82:14
let (gpu_device, cmd_queue) = futures::executor::block_on(async {
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
compatible_surface: Some(&surface),
})
.await
.expect("Request adapter");
[nix-shell:~/computing/roc]$ glxgears
glxgears: symbol lookup error: /nix/store/mij848h2x5wiqkwhg027byvmf9x3gx7y-glibc-2.33-50/lib/libdl.so.2: undefined symbol: _dl_catch_error_ptr, version GLIBC_PRIVATE
[nix-shell:~/computing/roc]$ vulkaninfo
ERROR: [Loader Message] Code 0 : libdrm.so.2: cannot open shared object file: No such file or directory
ERROR: [Loader Message] Code 0 : libLLVM-12.so: cannot open shared object file: No such file or directory
ERROR: [Loader Message] Code 0 : libGLX_nvidia.so.0: cannot open shared object file: No such file or directory
Cannot create Vulkan instance.
This problem is often caused by a faulty installation of the Vulkan driver or attempting to use a GPU that does not support Vulkan.
ERROR at /build/source/vulkaninfo/vulkaninfo.h:687:vkCreateInstance failed with ERROR_INCOMPATIBLE_DRIVER
[nix-shell:~/computing/roc]$ which vulkaninfo
/nix/store/9bn3gwiw64bdxi7k9a2h39974c39cs89-vulkan-tools-1.2.189.1/bin/vulkaninfo
totally not working
At least hello world works now
Installed nixGL, and now another library panics. I think I'll not use roc-editor then.
Hi Locria, sorry about this, it sounds very frustrating.
The roc editor is still a WIP and not ready yet to replace your favorite editor, I'll make sure to mention this in the BUILDING_FROM_SOURCE file.
The editor installation process will be much improved in the near future.
I was able to reproduce this error locally and will look at it soon.
This is the fix for when you have a Nvidia GPU:
# outside of nix shell:
nix-channel --add https://github.com/guibou/nixGL/archive/main.tar.gz nixgl && nix-channel --update
nix-env -iA nixgl.auto.nixVulkanNvidia
# does not work with nix-shell --pure
nix-shell
# 460.91.03 may be different for you, type nixVulkanNvidia and press tab to autocomplete for your version
nixVulkanNvidia-460.91.03 cargo run edit
I'll post a fix for integrated intel graphics soon (after I verified it).
Fixing nixGL with integrated intel graphics is going to take some time.
I've had no problems in running the tests while writing builtins, but I just tried the REPL on macOS and it just fail upon evaluating any Roc code. Seems like it can't find a given dylib. Any ideas?
Screenshot-2021-11-03-at-12.41.57.png
Hmm something else must be going on. All tests are failing since I updated my branch with latest trunk
.
Screenshot-2021-11-03-at-12.49.52.png
Problems averted. Turns out I had to upgrade my CLT since upgrading to macOS Monterey. All good now. :smile:
Looks like I get a failing test case though when running cargo test
. This is on macOS 12.0.1, running Rust 1.56.0 and Zig 0.8.1.
Screenshot-2021-11-03-at-13.11.34.png
Rerunning the tests using cargo test -p test_gen --lib
gave me the following error:
Screenshot-2021-11-03-at-13.39.39.png
Rerunning the tests inside of lldb
breaks on gen_primitives::lambda_set_enum_byte_byte
, but running the test in isolation doesn't cause any issues.
I've never used tools such as gdb
, lldb
and valgrind
, so I'm not really sure how to debug this. I'd love to pair on it if someone wants to.
Not sure if this helps or not, but running cargo test --release -p test_gen --lib
also cause the same issue. So it's persistent in both debug and release builds.
probably another case of macos being more strict, let me run this with valgrind
and for you to follow along, I put the test into its own file (I pick examples/benchmarks/Scratchpad.roc
for this
app "scratchpad"
packages { base: "platform" }
imports [base.Task]
provides [ main ] to base
main : Task.Task {} []
main =
r : [ Red, Green, Blue ]
r = Red
g : [ Red, Green, Blue ]
g = Green
p1 = (\u -> r == u)
p2 = (\u -> g == u)
oneOfResult = List.map [p1, p2] (\p -> p Green)
when List.len oneOfResult is
n -> Task.putLine (Str.fromInt n)
Now we can compile this. I use the --debug
flag, which will give extra info like line numbers. It requires you install debugir
. If you haven't, just run this and the error message will point you to where to get it from:
cargo run -- --debug examples/benchmarks/Scratchpad.roc
Now, from examples/benchmarks
, we can run valgrind
valgrind --leak-check=full --track-origins=yes ./scratchpad
Which gives a bunch of errors
==346834== Memcheck, a memory error detector
==346834== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==346834== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==346834== Command: ./scratchpad
==346834==
==346834== Invalid write of size 8
==346834== at 0x152714: ??? (Scratchpad.ll:1665)
==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593)
==346834== by 0x1112A0: main (host.zig:103)
==346834== Address 0x4c05060 is 6 bytes after a block of size 26 alloc'd
==346834== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==346834== by 0x110D57: roc_alloc (host.zig:48)
==346834== by 0x1526F2: ??? (Scratchpad.ll:1651)
==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593)
==346834== by 0x1112A0: main (host.zig:103)
==346834==
==346834== Invalid read of size 8
==346834== at 0x152850: ??? (Scratchpad.ll:1764)
==346834== by 0x152725: ??? (Scratchpad.ll:1668)
==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593)
==346834== by 0x1112A0: main (host.zig:103)
==346834== Address 0x4c05059 is 25 bytes inside a block of size 26 alloc'd
==346834== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==346834== by 0x110D57: roc_alloc (host.zig:48)
==346834== by 0x1526F2: ??? (Scratchpad.ll:1651)
==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593)
==346834== by 0x1112A0: main (host.zig:103)
==346834==
==346834== Conditional jump or move depends on uninitialised value(s)
==346834== at 0x152766: ??? (Scratchpad.ll:1681)
==346834== by 0x15285A: ??? (Scratchpad.ll:1765)
==346834== by 0x152725: ??? (Scratchpad.ll:1668)
==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593)
==346834== by 0x1112A0: main (host.zig:103)
==346834== Uninitialised value was created by a heap allocation
==346834== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==346834== by 0x110D57: roc_alloc (host.zig:48)
==346834== by 0x1526F2: ??? (Scratchpad.ll:1651)
==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593)
==346834== by 0x1112A0: main (host.zig:103)
==346834==
2
runtime: 17.481ms
==346834==
==346834== HEAP SUMMARY:
==346834== in use at exit: 0 bytes in 0 blocks
==346834== total heap usage: 2 allocs, 2 frees, 36 bytes allocated
==346834==
==346834== All heap blocks were freed -- no leaks are possible
==346834==
==346834== For lists of detected and suppressed errors, rerun with: -s
==346834== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
That --debug
flag also make sure the LLVM IR is written to Scratchpad.ll
, so we can inspect it. Usually it makes most sense to work from the top error downward. In this case, that line points us to this LLVM IR
%roc_alloc = tail call i8* @roc_alloc(i64 26, i32 1)
...
%.repack22 = getelementptr inbounds i8, i8* %roc_alloc, i64 32
where we allocate something that is 26 bytes, but then get a pointer to its 32th byte. That's an out of bounds access, and definitely a bug
Kevin Sjöberg said:
I've never used tools such as
gdb
,lldb
andvalgrind
, so I'm not really sure how to debug this. I'd love to pair on it if someone wants to.
If your ever interested in learning more about these tools, I am willing to pair. Just DM me. I have used them quite a bit, especially since I tend to deal with low level stuff within roc.
Folkert de Vries said:
and for you to follow along, I put the test into its own file (I pick
examples/benchmarks/Scratchpad.roc
for thisapp "scratchpad" packages { base: "platform" } imports [base.Task] provides [ main ] to base main : Task.Task {} [] main = r : [ Red, Green, Blue ] r = Red g : [ Red, Green, Blue ] g = Green p1 = (\u -> r == u) p2 = (\u -> g == u) oneOfResult = List.map [p1, p2] (\p -> p Green) when List.len oneOfResult is n -> Task.putLine (Str.fromInt n)
Now we can compile this. I use the
--debug
flag, which will give extra info like line numbers. It requires you installdebugir
. If you haven't, just run this and the error message will point you to where to get it from:cargo run -- --debug examples/benchmarks/Scratchpad.roc
Now, from
examples/benchmarks
, we can run valgrindvalgrind --leak-check=full --track-origins=yes ./scratchpad
Which gives a bunch of errors
==346834== Memcheck, a memory error detector ==346834== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al. ==346834== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info ==346834== Command: ./scratchpad ==346834== ==346834== Invalid write of size 8 ==346834== at 0x152714: ??? (Scratchpad.ll:1665) ==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593) ==346834== by 0x1112A0: main (host.zig:103) ==346834== Address 0x4c05060 is 6 bytes after a block of size 26 alloc'd ==346834== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==346834== by 0x110D57: roc_alloc (host.zig:48) ==346834== by 0x1526F2: ??? (Scratchpad.ll:1651) ==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593) ==346834== by 0x1112A0: main (host.zig:103) ==346834== ==346834== Invalid read of size 8 ==346834== at 0x152850: ??? (Scratchpad.ll:1764) ==346834== by 0x152725: ??? (Scratchpad.ll:1668) ==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593) ==346834== by 0x1112A0: main (host.zig:103) ==346834== Address 0x4c05059 is 25 bytes inside a block of size 26 alloc'd ==346834== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==346834== by 0x110D57: roc_alloc (host.zig:48) ==346834== by 0x1526F2: ??? (Scratchpad.ll:1651) ==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593) ==346834== by 0x1112A0: main (host.zig:103) ==346834== ==346834== Conditional jump or move depends on uninitialised value(s) ==346834== at 0x152766: ??? (Scratchpad.ll:1681) ==346834== by 0x15285A: ??? (Scratchpad.ll:1765) ==346834== by 0x152725: ??? (Scratchpad.ll:1668) ==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593) ==346834== by 0x1112A0: main (host.zig:103) ==346834== Uninitialised value was created by a heap allocation ==346834== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==346834== by 0x110D57: roc_alloc (host.zig:48) ==346834== by 0x1526F2: ??? (Scratchpad.ll:1651) ==346834== by 0x152628: roc__mainForHost_1_exposed_generic (Scratchpad.ll:1593) ==346834== by 0x1112A0: main (host.zig:103) ==346834== 2 runtime: 17.481ms ==346834== ==346834== HEAP SUMMARY: ==346834== in use at exit: 0 bytes in 0 blocks ==346834== total heap usage: 2 allocs, 2 frees, 36 bytes allocated ==346834== ==346834== All heap blocks were freed -- no leaks are possible ==346834== ==346834== For lists of detected and suppressed errors, rerun with: -s ==346834== ERROR SUMMARY: 3 errors from 3 contexts (suppressed: 0 from 0)
That
--debug
flag also make sure the LLVM IR is written toScratchpad.ll
, so we can inspect it. Usually it makes most sense to work from the top error downward. In this case, that line points us to this LLVM IR%roc_alloc = tail call i8* @roc_alloc(i64 26, i32 1) ... %.repack22 = getelementptr inbounds i8, i8* %roc_alloc, i64 32
where we allocate something that is 26 bytes, but then get a pointer to its 32th byte. That's an out of bounds access, and definitely a bug
This was super helpful! How did you know which test to use? To me it looked like it was failing randomly on different test cases.
this was the one that you said failed. I'd usually use lldb to find out where the segfault happens
I see. Are you looking into it now or should I give it a shot myself?
I'm looking at it, you can give it a go too. My theory is that we're allocating too little memory here, likely not taking alignment into account
I got it
can you check the tests with this PR https://github.com/rtfeldman/roc/pull/1885
Sure. I’ll try it out. Really impressed with your debugging skills. Would love to know more about how you ended up finding where the problem was. 🙂
@Folkert de Vries seems to have fixed it! Get another failure, but I think it's unrelated. It's the hello_swift one.
hm, gen_tags
fails for me on that branch on x64 macOS
test gen_tags::false_is_false ... ok
test gen_tags::applied_tag_just_enum ... ok
test gen_tags::alignment_in_multi_tag_construction_two ... ok
test_gen-ef19d83dce25afb6(25024,0x700007630000) malloc: *** error for object 0x7fee1a1705d0: pointer being freed was not allocated
test_gen-ef19d83dce25afb6(25024,0x700007630000) malloc: *** set a breakpoint in malloc_error_break to debug
I'm also on x64. I had a failure initially, but after running cargo clean
and then cargo test
they all seem to pass consistently.
interesting - I ran cargo clean
and now hello_swift
is failing, but gen_tags
is still failing :laughing:
$ cargo test --lib gen_tags
running 54 tests
test gen_tags::applied_tag_just_enum ... ok
test gen_tags::alignment_in_multi_tag_construction_two ... ok
test gen_tags::applied_tag_just_ir ... ok
test gen_tags::applied_tag_just ... ok
error: test failed, to rerun pass '-p test_gen --lib'
Caused by:
process didn't exit successfully: `/Users/rtfeldman/code/roc/target/debug/deps/test_gen-ef19d83dce25afb6 gen_tags` (signal: 11, SIGSEGV: invalid memory reference)
can you runlldb /Users/rtfeldman/code/roc/target/debug/deps/test_gen-ef19d83dce25afb6 -- gen_tags
that opens up a repl thing, then run run
and then bt
and that should show you which test case is responsible
running 54 tests
test gen_tags::applied_tag_just ... ok
test gen_tags::applied_tag_just_ir ... ok
test_gen-ef19d83dce25afb6(28983,0x700007235000) malloc: *** error for object 0x113057d00: pointer being freed was not allocated
test_gen-ef19d83dce25afb6(28983,0x700007235000) malloc: *** set a breakpoint in malloc_error_break to debug
Process 28983 stopped
* thread #9, name = 'gen_tags::applied_tag_function_result', stop reason = signal SIGABRT
frame #0: 0x00007fff202e492e libsystem_kernel.dylib`__pthread_kill + 10
libsystem_kernel.dylib`__pthread_kill:
-> 0x7fff202e492e <+10>: jae 0x7fff202e4938 ; <+20>
0x7fff202e4930 <+12>: movq %rax, %rdi
0x7fff202e4933 <+15>: jmp 0x7fff202dead9 ; cerror_nocancel
0x7fff202e4938 <+20>: retq
yup valgrind shows some issues for that one too
looks like that macos CI machine would be really valuable
for sure :big_smile:
I can spend some more time on that after next week's conferences
@Richard Feldman do you remember when this worked last? because I think we're hitting a more fundamental problem with our RC insertion here
and I don't see why it would be recently introduced
I'll git bisect it!
bisect says 5cb7dbd3cccf4b4af6b949a4e2d06485cbf49289 is the first bad commit
I love a good git bisect
I’m gonna try to get a build today on my M1 Max, finally done configuring it
Richard Feldman said:
bisect says 5cb7dbd3cccf4b4af6b949a4e2d06485cbf49289 is the first bad commit
hmm well maybe it does not crash but it still gives valgrind errors before that commit
does it still give valgrind errors even if you cherry-pick
the fix from the branch? :thinking:
Roc still can't run on Arch Linux with official packages from pacman
.
How's how to reproduce it in Vagrant:
https://roc.zulipchat.com/#narrow/stream/304641-ideas/topic/Faster.20builds.20and.20reproducible.20development.20environment/near/260232240
Roc still can't run on Arch Linux with official packages from
pacman
.
What specifically is causing an issue for that? I have had roc running on arch before.
Is it specifically an issue of needing software from the aur
or something different like versioning issues?
inkwell
What about it? Issues with llvm version/dev build to use with inkwell?
Richard Feldman said:
hm,
gen_tags
fails for me on that branch on x64 macOStest gen_tags::false_is_false ... ok test gen_tags::applied_tag_just_enum ... ok test gen_tags::alignment_in_multi_tag_construction_two ... ok test_gen-ef19d83dce25afb6(25024,0x700007630000) malloc: *** error for object 0x7fee1a1705d0: pointer being freed was not allocated test_gen-ef19d83dce25afb6(25024,0x700007630000) malloc: *** set a breakpoint in malloc_error_break to debug
It's now failing for me as well. So yeah, still an issue.
Lucas Rosa said:
I’m gonna try to get a build today on my M1 Max, finally done configuring it
@Lucas Rosa I almost have a build with nix working on my M1 mac mini.
Richard Feldman said:
does it still give valgrind errors even if you
cherry-pick
the fix from the branch? :thinking:
yes, it makes sense that this is a problem
What we do is we infer a borrow signature first for List.map
(or any lowlevel that takes a function argument), and only later for the function that we pass in practice. That means in this case that List.map
thinks that the passed function borrows the element, while in practice it owns it.
and therefore it's freed twice
ahh gotcha
I guess I don't need to look into it then?
ok here we go, finally running the tests on the M1 Max
some failing tests, probably my fault, gonna try the repl now
repl works fine :p
ok this is good enough for me to start getting some work done, I'll sort out why I have failing tests later
Anton said:
Lucas Rosa said:
I’m gonna try to get a build today on my M1 Max, finally done configuring it
Lucas Rosa I almost have a build with nix working on my M1 mac mini.
oh super nice, I'll give it a try as well :)
but yo, this builds super fast lol, it's almost scary :laughter_tears:
rm -rf target
time cargo test -p test_gen gen_dict
223.99s user 18.11s system 549% cpu 44.097 total
@Folkert de Vries good numbers or na? ^
which time is the relevant here? I always forget
if it's the 18 seconds then that's very good
system I think
I forget too lol
although 223s is still pretty fast considering it had to compile most of the crates before running the tests
true
Is there a guide somewhere about how to enable M1 support? Mabye a specific branch?
I didn't really do much outside of brew install llvm@12
, but I've only ran a few tests and the repl which is usually enough for me to get some work done. What command did you run or what code did you try that is giving you trouble?
I finally nailed it. Roc builds and runs on my MacBook Pro just fine. :tada:
According to CONTRIBUTING.md I have to talk to an existing contributor about the pull request that I want to make. Who shall I talk to?
A bit of a problem as well for me, my Mac is running low on disk space (30GB left out of 256GB). There's nothing I can do to clean up some space. That guide is telling me to run tests in Earthly prior to making a PR. Unfortunately, I won't be able to run them now. :( Not until I have access to my home PC where I can run Linux. The fun part is that Earthly won't exercise any of the macOS-specific stuff then as far as I can tell, will it?
I've never installed Earthly or used it and I think that's fine
I wouldn't worry about earthly. It is what CI runs and is nice if you really want to make sure a pr is good, but doesn't matter a ton for local testing.
Go ahead and just make a branch and then create a PR.
The main thing about talking to existing contributors is probably for if you are going to make larger changes. Don't want to waste effort when multiple people work on the same thing or someone adds features in a way that fundamentally Roc doesn't want. But for bug fixes and getting the programming working on a new system, just opening a PR should be great.
OK, what's the procedure then? Shall I push a new branch with the fix, if so is there any specific format for how to name it?
yes make a branch. There is no naming format, pick something descriptive and you should be good
Who to add into reviewers of this PR? https://github.com/rtfeldman/roc/pull/1890
Trying Roc for the first time (for advent of code; not sure I should post there instead), but getting this while trying cargo build
:
thread 'main' panicked at 'zig failed: error: AccessDenied
', compiler/builtins/build.rs:150:17
Does that look familiar to anyone? Fresh install of zig 0.8.0.
interesting
how did you install zig?
Downloaded the 0.8.0 binary from here: https://ziglang.org/download/
I managed to build and run hello world in zig, so at least the installation isn't completely broken
what os are you on?
I think that happens when you run the compiler in the wrong directory
and then some path does not work
all commands should be executed from the top directory
I'm on MacOS/aarch64. I'm running cargo build from the project root (i.e. the folder with .git
)
using nix or direct install of everything?
Direct installed everything. Rust, zig, llvm
Maybe I should give nix a try
maybe just chmod that whole builtins directory?
it does seem vaguely familiar, but I don't remember any details
Otherwise, it is possible an issue with cache dir resolution for some reason, like is mentioned here: https://github.com/ziglang/zig/issues/6810
Though, not nix specific as in the linked issue
Oh, I see what the problem is. I totally created this problem myself. Had copied something from another user and had to chown
it. Sorry for the trouble; should have caught it myself
makes sense, all good :)
Anyone know what to do about this?
error: failed to run custom build command for `roc_builtins v0.1.0 (C:\Users\taylo\Documents\Projects\roc\compiler\builtins)`
Caused by:
process didn't exit successfully: `C:\Users\path\to\roc\target\debug\build\roc_builtins-f32964a2162d4b2f\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: \\?\C:\Users\path\to\roc\compiler\builtins\bitcode\builtins-host.ll
--- stderr
thread 'main' panicked at 'zig failed:
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
at System.IO.Directory.InternalGetCurrentDirectory(Boolean checkHost)
at shim.ShimProgram.Main(String[] args)
', compiler\builtins\build.rs:150:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Hi @Taylor Allred,
I notice the C:\
in your path, are you using windows or perhaps the Windows Subsystem for Linux?
Hi all! Is there a way to specify the install path of Zig?
I mainly develop using Zig so the one installed in my $PATH is the master version.
So in short, I'd like to overwrite what's in my $PATH and specify the installation directory of zig 0.8.0 when building the Roc compiler from source.
Hi Luuk,
I've made issue #2189 to provide a nice solution for this, until that is done you can either:
Command::new("zig")
with say Command::new("zig8")
. This replacement may not cover all cases. You could temporarily rename your zig
command to notzig
and see where errors occur and then replace the use of zig there with zig8.Thanks Anton!
As all I have to do is test some changes, I'll just use option 2 for now :)
(Also thank you for making the issue).
Hi LuuK :)
Hi! I'm trying to build roc rn for the first time.
I just installed zig, and when I'm running cargo build I get the following error:
error: failed to run custom build command for `roc_builtins v0.1.0 (G:\Projects\roc\compiler\builtins)`
Caused by:
process didn't exit successfully: `G:\Projects\roc\target\debug\build\roc_builtins-4fc5c156ddb0b51a\build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: \\?\G:\Projects\roc\compiler\builtins\bitcode\builtins-host.ll
--- stderr
thread 'main' panicked at 'zig failed:
Unhandled Exception: System.ArgumentException: Illegal characters in path.
at System.Security.Permissions.FileIOPermission.EmulateFileIOPermissionChecks(String fullPath)
at System.IO.Directory.InternalGetCurrentDirectory(Boolean checkHost)
at shim.ShimProgram.Main(String[] args)
', compiler\builtins\build.rs:157:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
I am on windows.
My windows user does have hebrew characters, but I don't know what it could be trying to access under user.
Maybe somebody knows what's up?
What version of Zig did you install? I believe Roc requires Zig v0.8.0 v0.8.1
I'm on macOS using Nix, so all I know about Roc+Windows is this warning
I'm not the right one to help you with this, but for more info on Roc's dependencies you could skim this and these
Thank you for responding, I downloaded zig 0.9, should I get 0.8.1?
I think I saw in another thread that you can build on windows but linking wont work
Yes, sorry, that's part of what I meant - Zig v0.9.0 support is coming soon
Ok, thx!
Anton said:
Hi Taylor Allred,
I notice theC:\
in your path, are you using windows or perhaps the Windows Subsystem for Linux?
Hi @Anton. Sorry for not responding way back when. I believe I was running on windows not in WSL. I'll try this again in both and see how it goes.
Anton has marked this topic as unresolved.
@Taylor Allred we did get building on windows working but running roc programs will not work because linking on windows still has to be implemented. Using WSL should work though.
Hi! I'm trying to build from source on an aarch64
Debian GNU/Linux system, using the latest in the trunk. I get the following error during the cargo build
$ cargo build
Compiling roc_linker v0.1.0 (/path-to/roc/linker)
error[E0308]: mismatched types
--> linker/src/lib.rs:676:40
|
676 | let c_buf: *const c_char = dynstr_data[dynstr_off..].as_ptr() as *const i8;
| ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
| |
| expected due to this
|
= note: expected raw pointer `*const u8`
found raw pointer `*const i8`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `roc_linker` due to previous error
I can get the build to succeed by changing from i8
to c_char
, as hinted by the error, but I'm not sure the implications of that... Has anybody encountered this before? I'm brand new to all of this but trying to learn :smile:
even after getting past that error with that naive change, I cannot get many of the cli_run tests to pass. Lots of this error
---- cli_run::cfold stdout ----
thread 'cli_run::cfold' panicked at 'roc build had stderr: thread '<unnamed>' panicked at 'Failed to rebuild host.zig - stderr of the `zig` command was:
error: UnknownOperatingSystem
', compiler/build/src/link.rs:1111:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', cli/src/build.rs:233:50
', cli/tests/cli_run.rs:87:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Any thoughts on how to proceed from here?
Regarding the first error, what version of rustc are you using?
The first change looks to be a bug on our part. No matter the rust version, we should be converting that to a c_char
instead of the exact numeric type. That should be a safe change.
Regarding the second, are you able to run “zig build” in examples/hello-world/zig-platform? the error message indicates it may be a zig problem
yeah, the first one is our bug - it looks like c_char is target-dependent https://doc.rust-lang.org/src/std/os/raw/mod.rs.html#92-135
Yes, I guess my system treats c_char as a u8 instead of an i8
I'm happy to open a PR for the first issue once I can get all my test failures fixed.
@Ayaz Hafiz I was able to get a successful zig build
in that directory you mentioned. I had to zig init-exe
first though? Sorry, I'm brand new to Rust, Zig, Roc, the works :smile: . I appreciate the help!
ah, this gives me the same zig UnknownOperatingSystem
error as above
$ cargo run examples/hello-world/zig-platform/helloZig.roc
I'll take another look through the docs to make sure I didn't miss something in all the installation steps
sorry, i have to hop off to work but i will try to take a deeper look tomorrow morning if you or another helpful friend are unable to resolve this by then!
no worries! I appreciate the help so far and will try to do my best to figure it out in the meantime
So zig biuld
was actually the wrong command here. We manually build the host with a more complex form of zig build-obj
with a solid number of flags
To start simpler and check if the compiler is working in general, can you try:
cargo run examples/hello-world/rust-platform/helloRust.roc
Since we know rust is installed and running happily.
Brendan Hansknecht said:
To start simpler and check if the compiler is working in general, can you try:
cargo run examples/hello-world/rust-platform/helloRust.roc
Yes, this works fine! I was testing that and several other examples that are using Rust platforms and they seem fine.
Good to know. So definitely a zig related issue. Can you try and run a zig hello world program on your computer, unrelated to roc.
Should just be:
mkdir hello-world
cd hello-world
zig init-exe
zig build run
yep that works, as does a more typical hello-world like the one quoted here https://ziglearn.org/#hello-world
just to double check, what does zig version
print?
0.8.1
Can you change compiler/build/link.rs:131
from target,
to dbg!(target),
?
I want to see what OS we are telling zig to compiler for.
Since that is apparently the issue
Side note, good change that commenting out that line and the line above it will fix the issue.
[compiler/build/src/link.rs:131] target = "aarch64-unknown-linux-gnu"
Brendan Hansknecht said:
Side note, good change that commenting out that line and the line above it will fix the issue.
yes, commenting out those two lines did allow me to successfully run the helloZig.roc file!
How is linux-gnu
an unknown operating system.
...zig bug?
based on the pattern I see hardcoded elsewhere in the file, it seems that the -unknown-
piece maybe shouldn't be present?
For example, we don't have that piece here https://github.com/rtfeldman/roc/blob/trunk/compiler/build/src/link.rs#L445
I think this might be what we're aiming to match? https://github.com/ziglang/zig/blob/88e98a0611b9fb41c1da026febac2467548bb129/tools/process_headers.zig#L63
so it should just be aarch64-linux-gnu
in my case
I will test that hardcoded to see if it solves my issue
yes, confirmed that hardcoding aarch64-linux-gnu
as the target lets me run the zig platform example locally. Seems like there's some synchronization that needs to be done with the target_triple_str
function and how it relates to the zig -target
mappings
The unknown should be part of the triple. It is the vendor. So on Macos it is apple.
On most things it is unknown.
Maybe zig just removed it cause it generally isn't useful even if it is part of the triple
these seem like relevant zig issues
the zig wiki also mentions some about how these targets are updated in that repo
Wow, so it actually is a zig issue...kinda
Feel free to add a special exceptions. Probably add a comment with a link to the issue.
Okay. I've gotta go for the night but am happy to work on this later this weekend
Thanks, all, for the assistance!
Yep. No rush
@Anton Hi, I ran into the same issue you did with nixGL. nixVulkanIntel cannot be installed from nix-channel. But when I clone the repo and try nix-env -f ./ -iA nixgl.auto.nixVulkanIntel
I still get error: attribute 'nixgl' in selection path 'nixgl.auto.nixVulkanIntel' not found
. What did you do? (or anybody else that got nixVulkanIntel to work)
What OS?
If actual nix os, I know their is s nix flakes PR rn due to it running into some bugs. Not sure if it is the solution though.
https://github.com/rtfeldman/roc/pull/2732
Hi Jurek, I'll take a look on Monday.
Brendan Hansknecht said:
What OS?
Arch Linux
I've opened a PR for my GNU/Linux + ARM build issues, though I still have a few tests which I have not been able to have succeed on my system (more details in the PR)
https://github.com/rtfeldman/roc/pull/2774
I'm just feeling my way through all of this so happy to have suggestions
Oh, extra note, some tests may not pass without much more work. I know that on M1 we have some bugs. Might affect you too.
gui
is very slow to build, so it may just need a bit longer (it can take, idk maybe up to 5/10 min the first time)
for astar
it would be interesting to see the valgrind output, that is valgrind valgrind --leak-check=full --track-origins=yes ./test-astar
in the examples/benchmarks
folder
@Jurek Breuninger I created an issue on the nixGL repo, resolving that should make it easy to fix things for your case.
Folkert de Vries said:
gui
is very slow to build, so it may just need a bit longer (it can take, idk maybe up to 5/10 min the first time)
you were right, it just took a while to build. However, I still can't run it successfully. I'll share the output here in case it help, but I haven't spent any time digging into it yet:
---- cli_run::gui stdout ----
thread 'cli_run::gui' panicked at 'roc build had stderr: ld: /home/jake/roc/examples/gui/platform/host.o:(.data..L_MergedGlobals+0x18): undefined reference to `__dso_handle'
ld: /usr/lib/aarch64-linux-gnu/libc_nonshared.a(pthread_atfork.oS): in function `__pthread_atfork':
(.text+0x0): undefined reference to `__dso_handle'
ld: (.text+0x4): undefined reference to `__dso_handle'
ld: /home/jake/roc/examples/gui/hello-gui: hidden symbol `__dso_handle' isn't defined
ld: final link failed: bad value
', cli/tests/cli_run.rs:87:13
Folkert de Vries said:
for
astar
it would be interesting to see the valgrind output, that isvalgrind valgrind --leak-check=full --track-origins=yes ./test-astar
in theexamples/benchmarks
folder
I'm not familiar with valgrind or how to use it yet, but here's the output (in a gist since it's so long) in case it helps you:
https://gist.github.com/SylvanSign/64d23f9c72e65359c0db4f0566bb0296
Hi, I'm sorry if messages in this thread are getting a bit repetitive with people getting some variation of the same error when building from source...
When I run cargo build
, I get this error:
error: failed to run custom build command for `roc_builtins v0.1.0 (/Users/nikitamounier/Desktop/roc/compiler/builtins)`
Caused by:
process didn't exit successfully: `/Users/nikitamounier/Desktop/roc/target/debug/build/roc_builtins-4cc28b6b1e39ca55/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /Users/nikitamounier/Desktop/roc/compiler/builtins/bitcode/builtins-host.ll
--- stderr
thread 'main' panicked at 'zig failed: error: unable to create compilation: FileNotFound
', compiler/builtins/build.rs:170:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: build failed
I'm running macOS Monterey on an M1 with the nix-shell. According to llvm-config --version
, I'm on LLVM 12.01, and according to zig version
I'm on zig 0.8.1. I'm able to run zig build run
on a simple hello-world zig project.
Any idea what I could be doing wrong?
Sometimes that just flakily fails on my M1 mac and I simply have to run cargo build twice. So try running it again before anything else
Hi! Yeah I've tried running cargo build a couple times now, quit my terminal session in between sometimes and all. No luck for me yet, still getting the same error message
Just a note, one general option is just to use nix and it should auto-magically work. Otherwise, I'll try to look into this more in a bit to figure out what is going on.
That's just the thing --- I am using nix (that's what I meant when I said I'm on an M1 with nix-shell), which makes it all the more perplexing...
Sorry, I missed the nix line. Can you run with RUST_BACKTRACE=1
I want to see which specific zig command is failing
Actually, I am able to reproduce in a pure shell. Let me debug.
Sure! Here's the stacktrace when I run with RUST_BACKTRACE=1
:
stack backtrace:
0: rust_begin_unwind
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/panicking.rs:107:14
2: build_script_build::run_command
at ./build.rs:170:17
3: build_script_build::generate_bc_file
at ./build.rs:134:5
4: build_script_build::main
at ./build.rs:39:5
5: core::ops::function::FnOnce::call_once
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Let me know if you'd like the RUST_BACKTRACE=full
version!
So I think something is likely messed up with how we setup zig with nix. In a pure nix shell we have some interesting behaviour:
[nix-shell:~/Projects/roc]$ mkdir test
[nix-shell:~/Projects/roc]$ cd test
[nix-shell:~/Projects/roc/test]$ zig init-exe
info: Created build.zig
info: Created src/main.zig
info: Next, try `zig build --help` or `zig build run`
[nix-shell:~/Projects/roc/test]$ zig build --help
error: unable to create compilation: FileNotFound
I think the files that are failing to compile are the zig build cache for the standard library or something of that nature. I think nix may be restricting file writing permissions. That is at least my first guess.
Potentially a work around is just making sure that people never use pure nix shells or use tools like direnv/lorri, but I am not sure if they would still run into the issue either way.
I :heart:️ Nix
I have been poking at this for a bit, and at least for now, I am unsure what specifically is going on. Though I did learn that gimmeMoreOfThoseSweetSweetFileDescriptors()
is a function in the zig compiler.
Oh, good news, this issue looks to be fixed with zig 0.9.1
Since the compiler is about to update zig versions, this should be fixed very soon.
The zig 0.9.1 branch isn't fully working, but @Nikita Mounier can you check if you can at least build the compiler on the update_zig_09
branch? (please git pull
I just pushed a change to it)
Sure, I'll give it a shot!
Building the compiler works!
The zig 0.9.1 branch isn't fully working
What should I look out for that isn't fully working for now?
some functions for strings <-> number conversion
and the tests fail because of memory errors
macos is rather strict in going out of bounds so if you see random segfaults, that might be it
I'll continue work on it tonight/over the weekend, so it should all be fixed soon
I see, thanks for the info. Should be fine for now for me to hack around a little with Roc
Sounds good, thanks a lot!
Ok actually although I'm able to build the compiler, I'm not able to compile a Roc file. When doing cargo run examples/hello-world/helloWorld.roc
, I get this error with this stacktrace:
🔨 Rebuilding host... Done!
thread 'main' panicked at 'Failed to execute command 'sw_vers -productVersion': Os { code: 2, kind: NotFound, message: "No such file or directory" }', compiler/build/src/link.rs:1006:10
stack backtrace:
0: rust_begin_unwind
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/panicking.rs:107:14
2: core::result::unwrap_failed
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1613:5
3: core::result::Result<T,E>::expect
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1255:23
4: roc_build::link::get_macos_version
at /Users/nikitamounier/Desktop/roc/compiler/build/src/link.rs:1003:22
5: roc_build::link::link_macos
at /Users/nikitamounier/Desktop/roc/compiler/build/src/link.rs:931:14
6: roc_build::link::link
at /Users/nikitamounier/Desktop/roc/compiler/build/src/link.rs:48:14
7: roc_cli::build::build_file
at /Users/nikitamounier/Desktop/roc/cli/src/build.rs:259:13
8: roc_cli::build
at /Users/nikitamounier/Desktop/roc/cli/src/lib.rs:332:27
9: roc::main
at /Users/nikitamounier/Desktop/roc/cli/src/main.rs:30:21
10: core::ops::function::FnOnce::call_once
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/ops/function.rs:227:5
Same thing happens with cargo run --release
.
I did a quick search on the Zulip chat to see if this error has already popped up for someone, but it seems like it hasn't. What do you think?
yeah this is one of those memory issues
I'm not sure whether this is helpful or not, but I get a different (probably related) error when running cargo run examples/algorithms/fibonacci.roc
:
thread '<unnamed>' panicked at 'TODO gracefully handle unsupported target: Triple { architecture: Aarch64(Aarch64), vendor: Apple, operating_system: Darwin, environment: Unknown, binary_format: Macho }', compiler/build/src/target.rs:75:14
stack backtrace:
0: rust_begin_unwind
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/panicking.rs:107:14
2: roc_build::target::target_zig_str
at ./compiler/build/src/target.rs:75:14
3: roc_build::link::rebuild_host
at ./compiler/build/src/link.rs:460:21
4: roc_cli::build::spawn_rebuild_thread::{{closure}}
at ./cli/src/build.rs:326:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', cli/src/build.rs:233:50
stack backtrace:
0: rust_begin_unwind
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/panicking.rs:107:14
2: core::result::unwrap_failed
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1613:5
3: core::result::Result<T,E>::unwrap
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1295:23
4: roc_cli::build::build_file
at ./cli/src/build.rs:233:28
5: roc_cli::build
at ./cli/src/lib.rs:332:27
6: roc::main
at ./cli/src/main.rs:30:21
7: core::ops::function::FnOnce::call_once
Lmk if there's anything else I can do to help!
huh, that unsupported target is weird. @Brendan Hansknecht how could that happen? you run roc on your M1 right?
I ran into that too when running a test yesterday, but it worked on a re-run. We should handle that target correctly: https://github.com/rtfeldman/roc/blob/37729c08cc8ed6d808e323d7c1ba5a8a79b58228/compiler/build/src/target.rs#L34-L38
I've been running most of the example files to see the different kind of errors I get, it seems like I only get the unsupported target error with algorithms/quicksort.roc, algorithms/fibonacci.roc, and effects/Effect.roc
For the other files it's just the memory-related one
This might not be useful, but can you share the output of uname -a; arch
?
Sure:
Darwin Nikitas-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Mon Feb 21 20:36:53 PST 2022; root:xnu-8020.101.4~2/RELEASE_ARM64_T8101 arm64 arm64 MacBookPro17,1 Darwin
bash: arch: command not found
What is the current commit of the repo you are building from?
Ok, I think I've confirmed that the unsupported-platform error only shows up when using a zig platform in the Roc file. For instance in examples/hello-world/helloWorld.roc, I get the usual memory-related error for c and rust, but only get the unsupported platform one when using zig. The two algorithm files and the Effects.roc file also use zig as the platform.
@Ayaz Hafiz
What is the current commit of the repo you are building from?
I'm on the update_zig_09 branch using the latest commit dcc876d03aa5df139a6f5402c9d348f5e1be184b
Yeah that makes sense, you're hitting a panic in the function that gets the target for building zig code. Looks like that commit is missing the branch for Darwin on Mac. I just pushed 29739876876335b5ab4ca79b04290c58bb7749ed to that branch that should fix it; can you try?
I'm actually also getting the same unsupported-platform error when using web-platform
in the helloWorld.roc. Not sure if that's related though
Sure, I'll give it a try
Ok, so I tried compiling algorithms/fibonacci.roc and hello-world/helloWorld.roc using zig-platform
, and I'm not getting the unsupported-platform error anymore, but I am getting a new kind of error:
thread '<unnamed>' panicked at 'Failed to rebuild host.zig - stderr of the `zig` command was:
/Users/nikitamounier/Desktop/roc/examples/algorithms/fibonacci-platform/host.zig:28:69: error: use of undeclared identifier 'c_void'
/Users/nikitamounier/Desktop/roc/examples/algorithms/fibonacci-platform/host.zig:29:84: error: use of undeclared identifier 'c_void'
/Users/nikitamounier/Desktop/roc/examples/algorithms/fibonacci-platform/host.zig:34:65: error: use of undeclared identifier 'c_void'
/Users/nikitamounier/Desktop/roc/examples/algorithms/fibonacci-platform/host.zig:45:31: error: use of undeclared identifier 'c_void'
/Users/nikitamounier/Desktop/roc/examples/algorithms/fibonacci-platform/host.zig:54:31: error: use of undeclared identifier 'c_void'
/Users/nikitamounier/Desktop/roc/examples/algorithms/fibonacci-platform/host.zig:63:29: error: use of undeclared identifier 'c_void'
', compiler/build/src/link.rs:1111:27
stack backtrace:
0: rust_begin_unwind
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/panicking.rs:107:14
2: roc_build::link::validate_output
at ./compiler/build/src/link.rs:1111:27
3: roc_build::link::rebuild_host
at ./compiler/build/src/link.rs:469:9
4: roc_cli::build::spawn_rebuild_thread::{{closure}}
at ./cli/src/build.rs:326:17
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', cli/src/build.rs:233:50
stack backtrace:
0: rust_begin_unwind
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/panicking.rs:107:14
2: core::result::unwrap_failed
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1613:5
3: core::result::Result<T,E>::unwrap
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/result.rs:1295:23
4: roc_cli::build::build_file
at ./cli/src/build.rs:233:28
5: roc_cli::build
at ./cli/src/lib.rs:332:27
6: roc::main
at ./cli/src/main.rs:30:21
7: core::ops::function::FnOnce::call_once
at /rustc/02072b482a8b5357f7fb5e5637444ae30e423c40/library/core/src/ops/function.rs:227:5
Okay I fixed the zig errors and I think it should actually work now. Can you pull and try?
Yep, I'm not getting the zig-specific errors anymore (except in interactive/effects.roc which I forgot to mention up above) – I'm only getting the memory-related errors now from before
Pushed compile error fixes for effects.roc now too, but there are segfaults there when you actually run it :)
Are arch
and sw_vers
present under your /usr/bin
?
Are
arch
andsw_vers
present under your/usr/bin
?
Yep!
Pushed compile error fixes for effects.roc now too, but there are segfaults there when you actually run it :)
Can confirm, same here.
Is /usr/bin
in your path? Your error with cargo run examples/hello-world/helloWorld.roc
is presumably because sw_vers
couldn't be run
You're right that's my mistake --- my default shell is fish, but I forgot that nix uses bash, so had to update my .bashrc path.
So I'm back to getting the same zig error as before (the c_void
) one from up above, with the same stacktrace, in interactive/tui.roc and hello-world/helloWorld.roc (on zig-platform
). Otherwise, everything else compiles very nicely! Just whenever I do some Stdin input (like on interactive/echo.roc), I get back a seg fault 11.
I think c_void
was just a change between zig 0.8.1 an 0.9.1. So the example probably hasn't been updated yet
It is now anyopaque
It's been working like a charm, until just recently where whenever I try to do a cargo build
or cargo run
, it's unable to compile the roc_cli
with:
error: linking with `cc` failed: exit status: 1
|
= note: "cc" "-arch" "arm64" ......
= note: ld: library not found for -ltinfo
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm not sure why this error is popping up now, I don't think I changed anything or inadvertently removed a file. I downloaded a clean build of the repo and all, but to no avail --- same error.
I've been looking around online to see how to fix the issue – I found this potential solution:
cd /usr/lib
ln -s libncurses.so.5 libtinfo.so.5
ln -s libtinfo.so.5 libtinfo.so
What do you think?
what does “which cc” say?
/usr/bin/cc
Is it as simple as me have some libraries missing from my PATH?
I think you want the cc
from nix. If you updated your bashrc, maybe you want to add /usr/bin
to the back of the path rather than the front?
btw that branch should be a lot more usable now, basically everything besides the wasm backend seems to at least work
there are some tricky memory-related issues still, but those won't come up often if you're just playing around
If you updated your bashrc, maybe you want to add
/usr/bin
to the back of the path rather than the front?
I actually ended up downloading a plugin that lets me use fish with nix. Weird thing is, all of the nix-related things like /Users/nikitamounier/.nix-profile/bin
are already at the front path.
Here's my PATH for reference:
/nix/var/nix/profiles/default/bin /Users/nikitamounier/.nix-profile/bin /usr/bin /opt/homebrew/opt/libpq/bin /opt/homebrew/opt/llvm@12/bin /usr/local/bin /Users/nikitamounier/.cargo/bin /opt/homebrew/bin //opt/homebrew/bin /Users/nikitamounier/.fig/bin /Users/nikitamounier/.fzf/bin /bin /usr/sbin /sbin /opt/X11/bin /Library/Apple/usr/bin /Library/TeX/texbin /Applications/kitty.app/Contents/MacOS
Are you in a nix-shell
?
In my nix shell I see a bunch of opaque paths to stuff in nix/store
at the front of my path
:face_palm: Forgot that nix-shell has a different PATH. Attempting to move usr/bin
to the end of the path, but fish is giving me a weirdly difficult time...
You were right! I was able to finally get the usr/bin
to move at the end of PATH, and now it all works. Maybe someone could add to BUILDING_FROM_SOURCE.md that people using nix-shell should do this? I'll be happy to open a PR
Feel free to send a PR! All your insights here would be valuable.
Folkert de Vries said:
btw that branch should be a lot more usable now, basically everything besides the wasm backend seems to at least work
Sounds good! Yeah, looks like Stdin
still doesn't work for me (getting a SIGSEGV), I guess I'll try to avoid that for now. Everything else works like a charm though!
Actually, it's only the effects-platform and the cli-platform (from examples/interactive) that segfault on user input, the rest work great!
Brendan Hansknecht said:
The zig 0.9.1 branch isn't fully working, but Nikita Mounier can you check if you can at least build the compiler on the
update_zig_09
branch? (pleasegit pull
I just pushed a change to it)
I see the Update to Zig 0.9 PR doesn't say WIP anymore – so this will merge with trunk/upstream soon?
yeah, likely somewhere in the next 14 days
merging it is disruptive because everyone needs to get a new zig + llvm version
so we don't want to do that before Richard records his demo, but soon after probably
Gotcha!
Yeah I guess it'll be a smoother experience for those of us who are on nix-shell
yeah and in general the upgrade process is a lot smoother now than it was in the past. We know (kinda) what we're doing now
but still, it's complex and we want to time it right
Trying to build Roc from GitHub repo sources on Ubuntu 20.04 running inside WSL (not WSL2).
Ran into this issue on trying to run nix-shell:
Build with /nix/store/m0xw42nwrlfznfasiqfzwdavi4421x32-ghc-8.10.7.
ghc-pkg: Couldn't open database /tmp/nix-build-niv-0.2.19.drv-0/setup-package.conf.d for modification: {handle: /tmp/nix-build-niv-0.2.19.drv-0/setup-package.conf.d/package.cache.lock}: hLock: invalid argument (Invalid argument)
error: builder for '/nix/store/k5cy1lsddvq61hni78jdfyls8rf2ybsk-niv-0.2.19.drv' failed with exit code 1
error: build of '/nix/store/10p69ddbzjzbln6zhpkxlgywlqm6ax3w-zig-0.8.1.drv', '/nix/store/ac6vy5ly0is5xr7jnhabr2kd975gvi6p-debugir.drv', '/nix/store/k5cy1lsddvq61hni78jdfyls8rf2ybsk-niv-0.2.19.drv' failed
Have you seen this error before?
Seems like this issue: https://github.com/NixOS/nixpkgs/issues/79441
Arm?
Just a regular 64 bit Windows on a Ryzen 7 3800X (x86) CPU.
We also have a flake.nix file, can you give that a try?
I'm installing Roc on a new installation of Ubuntu 20.04. Installed nix and all the packages. But now I keep getting this error. Any ideas how to fix it?
[nix-shell:~/code/roc]$ nix rebuild
nix: /nix/store/nprym6lf8lzhp1irb42lb4vp8069l5rj-glibc-2.32-54/lib/libc.so.6: version `GLIBC_2.33' not found (required by /nix/store/dd8swlwhpdhn6bv219562vyxhi8278hs-gcc-10.3.0-lib/lib/libstdc++.so.6)
Actually I still seem to be able to run cargo
and things, so it doesn't seem to be really blocking me
OK this is actually blocking me for some commands
[nix-shell:~/code/roc]$ perf record target/debug/roc build examples/false-interpreter/False.roc
/bin/bash: /nix/store/wgp4l0jl7hm510x5615qsv4xikybzqb3-ncurses-6.2/lib/libtinfo.so.6: no version information available (required by /bin/bash)
/bin/bash: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /nix/store/wgp4l0jl7hm510x5615qsv4xikybzqb3-ncurses-6.2/lib/libtinfo.so.6)
Anyone else using Ubuntu 20.04 with nix? Have you seen anything like this? Did you solve it?
You can use the flake.nix:
nix develop
(instead of nix-shell)building will spam a different ncurses message but as far as I could tell that one does not affect anything.
Hi! I am having trouble compiling from source in an ubuntu VM running on an M1 mac.
nix develop
which said: Did you mean devShell?
I solved this by adding "aarch64-linux" to the supportedSystems in the flake.nix file.
cargo run help
and cargo build
which says: --> crates/linker/src/lib.rs:505:65
|
505 | ... let c_str = unsafe { CStr::from_ptr(str_bytes.as_ptr() as *const i8) };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
|
= note: expected raw pointer `*const u8`
found raw pointer `*const i8`
error[E0308]: mismatched types
--> crates/linker/src/lib.rs:1811:40
|
1811 | let c_buf: *const c_char = dynstr_data[dynstr_off..].as_ptr() as *const i8;
| ------------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `u8`, found `i8`
| |
| expected due to this
|
= note: expected raw pointer `*const u8`
found raw pointer `*const i8`
For more information about this error, try `rustc --explain E0308`.
error: could not compile `roc_linker` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Has anyone seen this before? it is a type mismatch from the linker, so this should have come up before right?
I installed everything from scratch following the build from source file.
My system is updated.
Could it be related to the issues with the silicon-Mac platform? Or versioning of some of the required libraries?
Eric Guedes Pinto has marked this topic as resolved.
Eric Guedes Pinto has marked this topic as unresolved.
Hi eric, we do not (yet?) support the aarch64-linux platform. You should be able to run on macos aarch64 though.
Ok, I'll do that
Thanks
The first error you got was not very clear, I'll make an issue for that.
Oh, the second issue is a bug I have run into before and keep forgetting to fix. We just need to update some types as the error says.
I developed that on x86, but didn't think about generic types because char is unsigned on some platforms and signed on others.
Should be an easy fix, I just am traveling and can't deal with it currently.
Hello, I am trying to build Roc from the latest commit on main on Windows, and it fails trying to link the symbols defined in roc_std.
https://github.com/roc-lang/roc/blob/38a7b6cef0efa339af5d6bed25dfd45f2163f682/crates/roc_std/src/lib.rs#L25-L32
This has happened with both the MSVC linker, and with LLD. I am not very familiar with linker failure modes so some guidance would be appreciated.
The specific error is:
note: lld: error: undefined symbol: roc_alloc
>>> referenced by C:\Users\RossSmyth\Documents\roc\crates\roc_std\src\lib.rs:51
>>> libroc_std-c05e5e25b8ffcb50.rlib(roc_std-c05e5e25b8ffcb50.46ifwog7cqzs4dpa.rcgu.o):(roc_std::roc_alloc_refcounted_help::h08260161a777fba6)
repeated for roc_dealloc and roc_realloc but with different object names.
error: could not compile `roc_load` due to previous error
After the undefined symbol error.
Windows support is very new :sweat_smile:
@Folkert de Vries is this a known issue?
I'll need some more info here. What are you trying to build (what is the command) and where exactly does it fail?
and yeah the status of windows is: I got it to work once on one machine a little while ago
LLVM_SYS_130_PREFIX
cd roc
git pull
(for MSVC linker)
cargo +1.61.0-msvc build
(For LLD)
$Env:RUSTFLAGS = "-Clinker=lld"
cargo +1.61.0-msvc build
(Both, but LLD's error message is much clearer. both have same missing symbols though)
Gets to building 416/434 crates (on roc_load) and fails with message above.
hmm, ok
do you know how to set environment variables? (I didn't really)
Yeah, that's the $Env:RUSTFLAGS = "-Clinker=lld"
we recently added a flag ROC_SKIP_SUBS_CACHE=1 cargo run
that should at least make that part work
in powershell at least. In cmd you use set RUSTFLAGS = -Clinker=lld
Alrigth I'll try it
Still fails, same location and error. Watching it closely as it is building it seems to fail specifically in the roc_load build.rs. I did do cargo +1.61.0-msvc clean
to be safe as well.
ok, that is weird and different from what I got
or, well, maybe not
so, basically, we want that build.rs script to do nothing
the thing is, msvc on windows does not seem to do dead code elimination, so those function, that are not used, still need to be there on windows for some reason
it is weird that lld also needs them to be there. But maybe this is really a windows-specific thing
I pushed some changes to the disable-subs-caching-windows
, can you try that?
hope that compiles, but I hope the idea is clear from https://github.com/roc-lang/roc/compare/disable-subs-caching-windows: we want to make sure the business logic just does not run on windows
or actually, it's not even there on windows. That's really the important part
I nuked my repo and recloned it just to be extra safe, checked out that branch, and same error. It is ignoring them because I get the "unused..." warnings, for example "warning: constant is never used: SKIP_SUBS_CACHE
"
I then tried to build it in release (cargo +1.61.0 build --release
) since LTO is on in release mode. There are spurious other linker failures in Zig in release before the failure above. Seems to do with file locking? But on a "good " run it still hit the failure above.
My next train of thought was maybe some weird parallel compilation race condition was messing things up, so I attempted to build with cargo +1.61.0-msvc build -j 0
. Same failure.
ok well you should now be able to just comment pretty much all of that build.rs away
and yes on windows for now at least you'll get a bunch of unused warnings in many places.
I just deleted the build file and roc_load finally built! But now the same error some from both roc_cli and roc_docs_cli :sad:
here's a new good first issue involving the repl! https://github.com/roc-lang/roc/issues/3793
if anyone is interested in picking it up, we'd be happy to help you get started on it!
yeah, you can disable that by removing it from the top-level Cargo.toml
and then you have something that works
That "worked" with some further modification. I'll write up something in an issue.
https://github.com/roc-lang/roc/issues/3805
I don't have much experience in git PRs nor much with Rust, but this seems very approachable. Where could I get started on it? (i also need to get my nix environment set up for the latest version of the compiler, but that's a different issue)
Awesome! Two places where the change would need to be made are at https://github.com/roc-lang/roc/blob/603f6b6613d7d8380a5690700918a3e64b5ae013/crates/repl_eval/src/eval.rs#L337-L345 and https://github.com/roc-lang/roc/blob/603f6b6613d7d8380a5690700918a3e64b5ae013/crates/repl_eval/src/eval.rs#L548-L552 - that's where we read back a string from the memory of the Roc code executed in the repl, and build up the AST representation of the string expression, which is then printed out. We'll want to change the StrLiteral
variant used in the cases where the string is multi-line.
The tests for the repl live in https://github.com/roc-lang/roc/blob/main/crates/repl_test/src/tests.rs - before you run them, you'll need to build the roc cli (cargo build -p roc_cli
).
Building everything works currently, but i run those tests after building the cli and i get a complaint about not finding GLIBC_2.34 for wasm3-sys. Checking the chat history here and on the issues page says using flakes solves this, but i am using flakes. My system libc version is 2.33 but in the nix develop environment it is 2.34. Any ideas? (This should be moved to #beginners > building from source )
5 messages were moved here from #contributing > good first issues by Richard Feldman.
Hi @Thomas Dwyer, I'll try to look at your issue today. Can you tell me the exact sequence of commands you ran?
well i entered the nix shell with nix develop
, built the roc cli using cargo build -p roc_cli
, then simply ran cargo test repl_test
(cargo test
has the same issue). i get the following error:
image.png
Thanks @Thomas Dwyer, I'll see if I can reproduce that.
I failed to reproduce this on NixOS, can you tell me what operating system you are on @Thomas Dwyer?
@Anton I am running WSL2 under my windows 10 pc. This is a single user nix installation.
I will try to reproduce that with the same setup this week, hopefully tomorrow.
@Thomas Dwyer can you try nix develop
followed by cargo clean
and cargo build
? Doing that fixed it for someone else with a very similar error.
@Anton Thank you, that works! really strange! Perhaps there should be a troubleshooting section in the installation file for cases like this. Nix is a strange beast for many people (including me), so we should aim to make its use as simple as possible. I really do wonder why nix was doing this, but I'm not too bothered now that it's solved.
Generally that happens when you build outside of nix and that pulls in the system Glibc then nix breaks due to linking to object files with the wrong glibc.
Yes indeed, simply put it's because you probably did cargo build
without doing nix develop
first. I will mention this in BUILDING_FROM_SOURCE and create an issue for it so people can also find it that way.
When running nix develop
, I get an error linking debugir. Does this sound like an issue with my Nix setup or somerhing else? (WSL2, Ubuntu 22.04). Happy to share logs if that would be helpful.
Hi @Bryce Miller, that is unexpected. A detailed error message and logs would indeed be very helpful.
I'm also setting up a 22.04 virtual machine, the error did not reproduce on 20.04.
@Anton Here's the log file. nix_log.txt
I believe it was working when I had 20.04 under WSL2 on my win10 box. Can't quite remember though.
Curious to find out whether you get the same error on your VM. If not, maybe something peculiar about WSL?
Here's the error that gets printed to the console, in case it helps:
error: builder for '/nix/store/8c55wxck5wxir0gsycdwxcdsa62ng41l-debugir.drv' failed with exit code 2;
last 10 log lines:
> /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: Main.cpp:(.text.startup+0xaf9): undefined reference to `llvm::raw_string_ostream::~raw_string_ostream()'
> /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: CMakeFiles/debugir.dir/Main.cpp.o:(.data.rel.ro._ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE[_ZTIN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE]+0x10): undefined reference to `typeinfo for llvm::cl::GenericOptionValue'
> /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: CMakeFiles/debugir.dir/Main.cpp.o:(.data.rel.ro._ZTIN4llvm2cl15OptionValueCopyIbEE[_ZTIN4llvm2cl15OptionValueCopyIbEE]+0x10): undefined reference to `typeinfo for llvm::cl::GenericOptionValue'
> /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: CMakeFiles/debugir.dir/Main.cpp.o:(.data.rel.ro._ZTVN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE[_ZTVN4llvm2cl15OptionValueCopyINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEEE]+0x18): undefined reference to `llvm::cl::GenericOptionValue::anchor()'
> /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: CMakeFiles/debugir.dir/Main.cpp.o:(.data.rel.ro._ZTVN4llvm2cl11OptionValueIbEE[_ZTVN4llvm2cl11OptionValueIbEE]+0x18): undefined reference to `llvm::cl::GenericOptionValue::anchor()'
> /nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: CMakeFiles/debugir.dir/Main.cpp.o:(.data.rel+0x0): undefined reference to `llvm::DisableABIBreakingChecks'
> collect2: error: ld returned 1 exit status
> make[2]: *** [CMakeFiles/debugir.dir/build.make:134: debugir] Error 1
> make[1]: *** [CMakeFiles/Makefile2:164: CMakeFiles/debugir.dir/all] Error 2
> make: *** [Makefile:91: all] Error 2
For full logs, run 'nix log /nix/store/8c55wxck5wxir0gsycdwxcdsa62ng41l-debugir.drv'.
error: 1 dependencies of derivation '/nix/store/6c85ff13cb9xdv6x6hmq3axrdkjj7gwc-nix-shell-env.drv' failed to build
Let me know if there's anything else I can share/test!
We've had a similar issue before that I never really figured out but it disappeared with different versions of nixpkgs. Can you check with git status
if the flake.lock
file changed?
no uncommitted changes here. Should be the same as what's on main
I was going to test on my M1 Mac last night but I managed to screw up my Nix installation lol. Last I checked it worked there.
Uhu, yeah we test nix on an M1 for every PR.
I failed to reproduce this in the VM on Ubuntu 22.04. I'll continue to investigate but if you want to unblock yourself you can just remove the debugir
line from inside sharedInputs = (with pkgs; [
in flake.nix
. debugir
is only used to debug a specific part of the compiler when needed, the build and tests can all pass without debugir
. A similar error as you're having now can occur for another nix dependency though.
Commented out that line and it worked! Some stuff isn't building now but I'm able to get into the shell at least. It also works without issue on my mac, so I can always use that. Definitely let me know if there is anything else I can do to help troubleshoot this, and I'll let you know if I find out anything new.
I'll let you now :) I'll try it out in WSL2 tomorrow.
Can you also share the errors for "Some stuff isn't building now"? Do those errors occur when doing cargo build
or is this still with nix develop
?
Doing nix develop
successfully puts me into the shell. cargo clean && cargo build
results in the following:
...
Compiling x11-dl v2.19.1
Compiling wgpu-core v0.12.2
error: failed to run custom build command for `wasi_libc_sys v0.0.1 (/home/bdm/src/contrib/roc/crates/wasi-libc-sys)`
Caused by:
process didn't exit successfully: `/home/bdm/src/contrib/roc/target/debug/build/wasi_libc_sys-ea0d16e6299e57fc/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=src/dummy.c
--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', crates/wasi-libc-sys/build.rs:33:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Here's a similar error I got on my mac when I tried tocargo build
before running cargo clean
.
error: failed to run custom build command for `roc_repl_wasm v0.0.1 (/Users/bryce/src/roc/crates/repl_wasm)`
Caused by:
process didn't exit successfully: `/Users/bryce/src/roc/target/debug/build/roc_repl_wasm-447f50ffdcb4a716/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
cargo:rerun-if-changed=src/repl_platform.c
--- stderr
thread 'main' panicked at 'Output {
status: ExitStatus(
unix_wait_status(
256,
),
),
stdout: "",
stderr: "wasm-ld: error: cannot open /Users/bryce/code/roc/target/debug/build/wasi_libc_sys-b55c70ecf1892372/out/zig-cache/o/1bb0d1cbfb762560ef47ddccdb2efdcf/compiler_rt.o: No such file or directory\nwasm-ld: error: cannot open /Users/bryce/code/roc/target/debug/build/wasi_libc_sys-b55c70ecf1892372/out/wasi-libc.a: No such file or directory\n",
}', crates/repl_wasm/build.rs:42:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
Oddly, after I got this error, cargo run repl
worked without running cargo clean
first. cargo clean && cargo build
fixed the build issue.
So to be clear, no problems on my Mac, but this is an issue that popped up and was easily fixable with cargo clean
.
You may have run cargo build
once without doing nix develop
first. Later trying to use nix with pre-built artifacts made without nix is known to lead to all kinds of problems. We mention this in BUILDING_FROM_SOURCE but I will improve the wording. To prevent this: tools like direnv or lorri can automatically put you in a nix shell whenever you cd
into the directory, I also like using starship which clearly shows if you are in a nix shell or not.
@Bryce Miller I failed to reproduce the debugir error with Ubuntu 22.04 on WSL. Because we are working on native windows support I'd like to end the investigation here.
Thanks for the tips! I believe I did run cargo build once before remembering to drop into the Nix shell. I just didn’t know how to clean up the mess beyond trying cargo clean.
Fair enough, you have higher priority things to work on! If I do manage to figure out a fix, should I share it here?
Thanks again for looking into this for me.
Update: I tried using the "Ubuntu 22.04.1" package from the Microsoft Store instead of the "Ubuntu" package. Nix shell and build worked flawlessly. Either I messed something up in the other environment, or there is some subtle difference in the way they are set up by default. Hope this helps for anyone else using WSL2.
Hi,
How can I just build a executable?
I try
nix develop
cargo install
and I get
error: found a virtual manifest at `/path/to/roc/Cargo.toml` instead of a package manifest
cargo build
Where is the binary?
Sorry, I forgot to say that I want a binary and not to run cargo run -- foo
every time
ah
/target/debug/roc
probably, or /target/release/roc
is you built with --release
you should symlink that though, and not move the binary; it uses some files with a relative path
Thanks, I was planning to do that (if I rebuild, I can just "do nothing")
The guide says:
If you want to load all dependencies automatically whenever you cd into roc, check out direnv. Then you will no longer need to execute nix develop first.
What environment variables do I add to direnv?
echo "use nix" >> .envrc
That should work if you have nix setup correctly and direnv installed through nix
That said, it is nicer to use lorri with nix
It basically rebuilds the nix environment behind the scenes and caches the nix environment better. So you can just use things without waiting on updates.
Bryce Miller said:
Doing
nix develop
successfully puts me into the shell.cargo clean && cargo build
results in the following:... Compiling x11-dl v2.19.1 Compiling wgpu-core v0.12.2 error: failed to run custom build command for `wasi_libc_sys v0.0.1 (/home/bdm/src/contrib/roc/crates/wasi-libc-sys)` Caused by: process didn't exit successfully: `/home/bdm/src/contrib/roc/target/debug/build/wasi_libc_sys-ea0d16e6299e57fc/build-script-build` (exit status: 101) --- stdout cargo:rerun-if-changed=build.rs cargo:rerun-if-changed=src/dummy.c --- stderr thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', crates/wasi-libc-sys/build.rs:33:10 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace warning: build failed, waiting for other jobs to finish...
Hello! I am coming back to Roc since last working on it around February. Trying to build from source now, I am hitting this exact error Bryce reported. For me, cargo clean
is not resolving. Has anyone else run into it?
I am hitting this issue on my mac.
Hi Chad, that error suggests that a previous Zig command failed. Maybe check what zig version
says? We require Zig 0.9.1. We first check to see if the environment variable ROC_ZIG
contains a path, and if not, we default to zig
.
Welcome back @Chad Stearns :)
Like Bryce, did you also do nix develop
first? Zig should definitely be the right version when using nix develop
.
Brendan Hansknecht said:
echo "use nix" >> .envrc
Thanks, it's working. However, every call of nix develop
, or entry through direnv, takes away about 10GB of disk space which quickly kills this resource constrained box. Part of that seems copying of roc-main
directory with all the compilation artifacts. nix-collect-garbage
on the other hand forces download & install of all dependencies again (and doesn't seem to free all the disk space anyway)
Is there a way to deal with this?
Yeah....nix can be annoying with storage space. I have never run out of space on my machine, so I can't imagine the 10 GB being consistently added without some other form of issue (though even a few times could be problematic). @Anton any ideas? Can we get nix to ignore the files? Especially the target folder? Theoretically, nix should be able to just change paths and not move any data, right?
I like using https://github.com/hercules-ci/gitignore.nix for this but it only makes sense for the shell.nix
/default.nix
combo. If you have a version of Nix that can use flakes, I'd recommend using use flake
in your .envrc
instead, as it'll ignore gitignored files automatically.
(although I think nix develop
uses flakes already so I am not sure what could be happening there.)
I think our shell.nix
was modified to be the same as nix develop
as well
Also, didn't realize direnv
can support flakes directly now. Might switch to that until lorri updates.
I switched away from Lorri a long time ago, FWIW. The only thing I miss is building in the background. I've got a direnv snippet loaded with home-manager that caches shells so that shell startup is negligible with just use nix
or use flake
without having to run a daemon.
I can send it to you if you'd like, but I think I just got it from the Nix wiki
No worries, found it.
I don't think compilation artifacts are copied, but once you run cargo build
after nix develop
they will appear in the nix/store/hash-source
folder.
@Arbil I would check your target folder to make sure that you don't have both release
and debug
folders. Your IDE may also generate compiler artifacts. I would delete the debug
folder and test building with cargo build --release -p name_of_crate_you_changed
and testing with cargo test --release -p name_of_crate_you_changed
to save storage space. I will send you a flake.nix tomorrow that does not contain the editor's dependencies, that should also save some space.
Anton said:
I don't think compilation artifacts are copied, but once you run
cargo build
afternix develop
they will appear in thenix/store/hash-source
folder.
Thank you. I've done a quick reformat of this box and it seems more managable this time. BTW, I'm using the vscode flake and 'arrow up' doesn't work in inbuilt terminal for 'previous command', is that normal?
the flake terminal and your normal terminal have different histories.
but up arrow should work within the history of your flake terminal
I'm using the vscode flake and 'arrow up' doesn't work in inbuilt terminal for 'previous command', is that normal?
Yeah it's not just the different histories, I also have this. I tried digging into it but came up empty, so I use the terminal in which I entered nix develop
.
Oh, weird
My terminal also looks like this:
nix_vscode_terminal.png
I wonder if it's because I use starship.rs
Mine looks similar though not identical. I don't use starship
@Arbil here is the flake.nix with all editor dependencies left out:
{
description = "Roc flake";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
# rust from nixpkgs has some libc problems, this is patched in the rust-overlay
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# to easily make configs for multiple architectures
flake-utils.url = "github:numtide/flake-utils";
# to be able to use vulkan system libs for editor graphics
nixgl = {
url = "github:guibou/nixGL";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, rust-overlay, flake-utils, nixgl }:
let supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" ];
in flake-utils.lib.eachSystem supportedSystems (system:
let
overlays = [ (import rust-overlay) ]
++ (if system == "x86_64-linux" then [ nixgl.overlay ] else [ ]);
pkgs = import nixpkgs { inherit system overlays; };
llvmPkgs = pkgs.llvmPackages_13;
# get current working directory
cwd = builtins.toString ./.;
rust =
pkgs.rust-bin.fromRustupToolchainFile "${cwd}/rust-toolchain.toml";
linuxInputs = with pkgs;
lib.optionals stdenv.isLinux [
valgrind # used in cli tests, see cli/tests/cli_run.rs
#vulkan-headers
#vulkan-loader
#vulkan-tools
#vulkan-validation-layers
#xorg.libX11
#xorg.libXcursor
#xorg.libXrandr
#xorg.libXi
xorg.libxcb
#alsa-lib
];
darwinInputs = with pkgs;
lib.optionals stdenv.isDarwin
(with pkgs.darwin.apple_sdk.frameworks; [
AppKit
CoreFoundation
CoreServices
CoreVideo
Foundation
Metal
Security
]);
# For debugging LLVM IR
#debugir = pkgs.stdenv.mkDerivation {
# name = "debugir";
# src = pkgs.fetchFromGitHub {
# owner = "vaivaswatha";
# repo = "debugir";
# rev = "b981e0b74872d9896ba447dd6391dfeb63332b80";
# sha256 = "Gzey0SF0NZkpiObk5e29nbc41dn4Olv1dx+6YixaZH0=";
# };
# buildInputs = with pkgs; [ cmake libxml2 llvmPackages_13.llvm.dev ];
# buildPhase = ''
# mkdir build
# cd build
# cmake -DLLVM_DIR=${pkgs.llvmPackages_13.llvm.dev} -DCMAKE_BUILD_TYPE=Release ../
# cmake --build ../
# cp ../debugir .
# '';
# installPhase = ''
# mkdir -p $out/bin
# cp debugir $out/bin
# '';
#};
sharedInputs = (with pkgs; [
# build libraries
cmake
git
python3
llvmPkgs.llvm.dev
llvmPkgs.clang
libxkbcommon
pkg-config
zig # roc builtins are implemented in zig, see compiler/builtins/bitcode/
# lib deps
libffi
libxml2
ncurses
zlib
libiconv
# faster builds - see https://github.com/roc-lang/roc/blob/main/BUILDING_FROM_SOURCE.md#use-lld-for-the-linker
llvmPkgs.lld
#debugir
rust
rust-bindgen
]);
in {
devShell = pkgs.mkShell {
buildInputs = sharedInputs ++ darwinInputs ++ linuxInputs
++ (if system == "x86_64-linux" then
[ pkgs.nixgl.nixVulkanIntel ]
else
[ ]);
LLVM_SYS_130_PREFIX = "${llvmPkgs.llvm.dev}";
# nix does not store libs in /usr/lib or /lib
NIX_GLIBC_PATH =
if pkgs.stdenv.isLinux then "${pkgs.glibc.out}/lib" else "";
LD_LIBRARY_PATH = with pkgs;
lib.makeLibraryPath
([ pkg-config stdenv.cc.cc.lib libffi ncurses zlib ]
++ linuxInputs);
NIXPKGS_ALLOW_UNFREE =
1; # to run the editor with NVIDIA's closed source drivers
};
formatter = pkgs.nixpkgs-fmt;
# You can build this package (the roc CLI) with the `nix build` command.
packages.default = import ./. { inherit pkgs; };
});
}
Thank you very much. Will use today
Hey @Anton @Brian Carroll . Nice to see you all. I am not on nix. When I do zig version
I do see 0.9.1
. I tried setting ROC_ZIG
just in case and I am still seeing the same error. Looking at the error again, it is exactly the same one as Bryce's (except for the directory names of course).
I see build.rs
now. I am going to try adding some debugs and printlns.
Yeah I can see that it is looking for my zig cache at:
/Users/chad/code/roc/target/debug/build/wasi_libc_sys-1aefd8d65824087d/out/zig-cache
but when I check that spot zig-cache
is not present
Screen-Shot-2022-10-23-at-12.20.02-AM.png
Hi Chad, I'd recommend adding some dbg prints to get the necessary values and executing zig build-exe...
manually from the same working dir.
Is there a more granular command to build the roc compiler than cargo build
in project root? This one builds some editor, wasm and repl stuff also
Rust let's you build specific packages. Otherwise, the compiler does have some feature flags that can reduce what is pulled in, but it is pretty limited in what can be removed
Hi,
Yesterday I made the upgrade of MacOS to Ventura 13.0, and now my build fails :cry:
I tried cargo clean
, but same output for cargo build
:
bash-5.1$ RUST_BACKTRACE=1 cargo build
Compiling roc_builtins v0.0.1 (/Users/ghigt/code/roc/source/crates/compiler/builtins)
Compiling serde v1.0.144
Compiling sha2 v0.10.2
Compiling clap_derive v3.2.18
Compiling futures-util v0.3.24
Compiling wasm-bindgen-macro-support v0.2.83
Compiling objc-foundation v0.1.1
Compiling bytemuck v1.12.1
Compiling object v0.29.0
Compiling roc_collections v0.0.1 (/Users/ghigt/code/roc/source/crates/compiler/collections)
error: failed to run custom build command for `roc_builtins v0.0.1 (/Users/ghigt/code/roc/source/crates/compiler/builtins)`
Caused by:
process didn't exit successfully: `/Users/ghigt/code/roc/source/target/debug/build/roc_builtins-4ce1b28dcf05f93e/build-script-build` (exit status: 101)
--- stdout
cargo:rerun-if-changed=build.rs
Compiling host ir to: /Users/ghigt/code/roc/source/crates/compiler/builtins/bitcode/builtins-host.ll
Compiling 64-bit bitcode to: /Users/ghigt/code/roc/source/crates/compiler/builtins/bitcode/builtins-host.bc
--- stderr
thread 'main' panicked at 'zig failed: thread 333562 panic: Darwin is handled separately via std.zig.system.darwin module
Unable to dump stack trace: debug info stripped
', crates/compiler/builtins/build.rs:240:21
stack backtrace:
0: rust_begin_unwind
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/panicking.rs:143:14
2: build_script_build::run_command
at ./build.rs:240:21
3: build_script_build::generate_bc_file
at ./build.rs:133:5
4: build_script_build::main
at ./build.rs:40:5
5: core::ops::function::FnOnce::call_once
at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
(I use nix develop
)
Also, the previous builds using MacOS 12.0 are now failing:
» 1+1
ld: warning: directory not found for option '-F/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/'
ld: library not found for -lSystem
/var/folders/y4/y9696g7j7hx_dhcfdlv9f4600000gn/T/.tmpOlm155/app.dylib: No such file or directory
I guess they change the location of the system library?
ah you're right, I currently have /Library/Developer/CommandLineTools/SDKs/MacOSX12.1.sdk/
brew is telling me to upgrade to XCode 14.1 instead of 14.0.1 but it is only in RC 2 and should be released in the next days, maybe it is related and will default to MacOSX.sdk
I don't know if I can ln
the folder
ok, after having the /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk
folder link, the previous builds work!
But still, I can't build new one any more
Zig has a branch up with a fix but that is for zig master, it'll probably take them some time to release 0.9.2 I suppose.
Thank you @Anton, so I guess we're not able to compile on MacOS Ventura until then
That will teach me to update too soon :sweat_smile:
Yeah, I've heard several macos/ios update horror stories before...
Would it be possible (following this answer https://github.com/ziglang/zig/issues/10478#issuecomment-1294313967) to make it run on Ventura using -target native-macos.12
?
I tried with a simple hello-world.zig
and it works, but I'm lost in the Roc repo to know where to put and try it
It's probably going to need to be added in multiple places. Based on the error you originally posted I would add -target native-macos.12
here to get started.
I tried to change this line, but without any result (I'm very new to Rust/Zig). Then I switched to build.zig but I can't find how to manage this object.
Did you get the exact same error? Feel free to post it again to make sure.
yes, it's like I did nothing
Maybe I'm doing something wrong, I changed it to:
run_command(
&bitcode_path,
&zig_executable(),
&[
"build",
zig_object,
"-target",
"native-macos.12",
"-Drelease=true",
],
0,
);
I think there are just more places you need to change the target
llvm generation needs to use the right target, but probably generic macos is good enough there, then the host needs to be built with the right target, and the final linking needs to use the right target
It would probably be good to make a single zig_cmd
function that is used everywhere instead of going through std::process::Command
in multiple places. I'll make an issue for that.
well, that does not always work. You need the flexibility of Command
sometimes
Could the zig_cmd
function not offer the same flexibility but still be centralized?
not sure what type you have in mind, is it fn zig_cmd() -> Command
?
Anoton we do lots of different things with Zig in different places. Sometimes we're compiling a host, sometimes an app, sometimes a preprocessed host, could be targeting WebAssembly or native, compiling C code or Zig code...
So it's not just the same thing duplicated all over the place. There may be some duplication but I'm skeptical we can write just one command to satisfy all these needs.
Oops, not an app! :sweat_smile: But the other stuff
I'm aware of that, the intent is not really to avoid duplication but to have one central function that allows us to easily track where in the code base zig is used. As Folkert suggested; fn zig_cmd() -> Command
would allow us to do this tracking without sacrificing any flexibility. You can still add args to the Command
that gets returned.
Perhaps it makes sense to eventually go to a slightly less flexible version of fn zig_cmd() -> Command
, but it is a good start.
Ok, so it looks out of my competence, I'll downgrade to MacOS Monterey until Roc migrate to zig 0.10.x (which looks to be released in the next 4 days)
To set expectations; I believe zig 0.10 requires us upgrading to llvm 14 which requires significant effort.
yeah if I were to guess, I'd guess we won't end up upgrading to Zig 0.10 until early 2023
mainly because we're currently focusing on Advent of Code experience (which naturally runs through December), the 0.10 upgrade isn't needed for any of that, and it's a significant project
Yes, I totally understand, so it's simpler - if I want to dive into the roc code and mess around with it - for me to downgrade
Done, everything's working fine now I'm back to MacOS 12!
For @Arbil and others who had this issue with the vscode terminal from inside nix:
nix_vscode_terminal.png
I was able to resolve it in this PR
Hi! I'm having an issue when building from source on macOS. cargo build
works fine, and cargo run repl
starts the repl, but when I enter anything it panics. I actually had the repl working fine when I initially set things up a few weeks ago, so I must have accidentally messed up my environment, but I can't figure out what changed. I'm using nix, and this is what happens after running cargo clean
, nix develop
, cargo run repl
and then entering a value in the repl. Any ideas what this error is related to?
» 123
ld: unknown option: -no_fixup_chains
thread 'main' panicked at '
___________
Linking command failed with status ExitStatus(unix_wait_status(256)):
Child { stdin: None, stdout: None, stderr: None, .. }
___________
', crates/compiler/build/src/link.rs:1464:5
stack backtrace:
0: rust_begin_unwind
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/std/src/panicking.rs:584:5
1: core::panicking::panic_fmt
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/panicking.rs:142:14
2: roc_build::link::llvm_module_to_dylib
at ./crates/compiler/build/src/link.rs:1464:5
3: roc_repl_cli::cli_gen::mono_module_to_dylib
at ./crates/repl_cli/src/cli_gen.rs:286:5
4: roc_repl_cli::cli_gen::gen_and_eval_llvm
at ./crates/repl_cli/src/cli_gen.rs:73:9
5: roc_repl_cli::repl_state::ReplState::eval_and_format
at ./crates/repl_cli/src/repl_state.rs:260:46
6: roc_repl_cli::repl_state::ReplState::step
at ./crates/repl_cli/src/repl_state.rs:122:46
7: roc_repl_cli::main
at ./crates/repl_cli/src/lib.rs:49:23
8: roc::main
at ./crates/cli/src/main.rs:194:35
9: core::ops::function::FnOnce::call_once
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/ops/function.rs:248:5
I tried it out using latest main and it seems to work for me. I'm on MacOS 12.6 using M2 silicon.
192-168-1-105:roc luke$ cargo clean
192-168-1-105:roc luke$ nix develop
192-168-1-105:roc luke$ cargo run repl
Compiling libc v0.2.135
[]... deleted extra lines ...[]
Compiling roc_docs v0.0.1 (/Users/luke/Documents/GitHub/roc/crates/docs)
Finished dev [unoptimized + debuginfo] target(s) in 1m 20s
Running `target/debug/roc repl`
The rockin’ roc repl
────────────────────────
Enter an expression, or :help, or :q to quit.
» 123
123 : Num * # val1
I was able to get this working by deleting "-no_fixup_chains" from crates/compiler/build/src/link.rs line 1283! Looks like it was added in December, so must have been before that when it was working for me. I am also on MacOS 12.6 but with an intel chip by the way
Brendan Hansknecht said:
echo "use nix" >> .envrc
is quite slow
$ cd roc
direnv: loading ~/git/roc-lang/roc/.envrc
direnv: using nix
direnv: ([/opt/homebrew/bin/direnv export zsh]) is taking a while to execute. Use CTRL-C to give up.
am I doing it right?
$ cat .envrc
use nix
PATH_add target/debug
The very first time is slow. Same with calling nix develop
for the first time. After that, it should be cached and fast.
Not sure about the second line though. What does it do? If it cause nix to reevaluate whenever target/debug
changes, that may break caching, but i have never used the PATH_add
command. So i am not truly sure.
My full .envrc
is:
use flake
nix_direnv_watch_file rust-toolchain.toml
First line at some point changed from use nix
to use flake
. Both should work cause our shell.nix
just points to the flake. Not sure the real difference
The second line is so that when I change the rust version to nightly (which I need for fuzzing and some random other times), it will force a re-evaluation
Also, just looked of PATH_add
, yeah, should be harmless. So probably just a matter of waiting for the first invocation that has to download and set everything up.
Brendan Hansknecht said:
First line at some point changed from
use nix
touse flake
. Both should work cause ourshell.nix
just points to the flake. Not sure the real difference
using use nix
, it's slow every time (not just first time)
using use flake
fails:
$ cd roc
direnv: loading ~/git/roc-lang/roc/.envrc
direnv: using flake
/bin/bash: eval:2231: conditional binary operator expected
/bin/bash: eval:2231: syntax error near `enableParallelBuilding'
/bin/bash: eval:2231: ` if ! [[ -v enableParallelBuilding ]]; then'
direnv: export +AR +AR_FOR_TARGET +AS +AS_FOR_TARGET +CC +CC_FOR_TARGET +CMAKE_FRAMEWORK_PATH +CMAKE_INCLUDE_PATH +CMAKE_LIBRARY_PATH +CMAKE_PREFIX_PATH +CONFIG_SHELL +CXX +CXX_FOR_TARGET +DETERMINISTIC_BUILD +HOST_PATH +IN_NIX_SHELL +LD +LD_DYLD_PATH +LD_FOR_TARGET +LD_LIBRARY_PATH +LLVM_SYS_130_PREFIX +MACOSX_DEPLOYMENT_TARGET +NIXPKGS_ALLOW_UNFREE +NIX_BINTOOLS +NIX_BINTOOLS_FOR_TARGET +NIX_BINTOOLS_WRAPPER_TARGET_HOST_aarch64_apple_darwin +NIX_BINTOOLS_WRAPPER_TARGET_TARGET_aarch64_apple_darwin +NIX_BUILD_CORES +NIX_CC +NIX_CC_FOR_TARGET +NIX_CC_WRAPPER_TARGET_HOST_aarch64_apple_darwin +NIX_CC_WRAPPER_TARGET_TARGET_aarch64_apple_darwin +NIX_CFLAGS_COMPILE +NIX_CFLAGS_COMPILE_FOR_TARGET +NIX_COREFOUNDATION_RPATH +NIX_DONT_SET_RPATH +NIX_DONT_SET_RPATH_FOR_BUILD +NIX_ENFORCE_NO_NATIVE +NIX_GLIBC_PATH +NIX_HARDENING_ENABLE +NIX_IGNORE_LD_THROUGH_GCC +NIX_INDENT_MAKE +NIX_LDFLAGS +NIX_LDFLAGS_FOR_TARGET +NIX_NO_SELF_RPATH +NIX_PKG_CONFIG_WRAPPER_TARGET_TARGET_aarch64_apple_darwin +NIX_STORE +NM +NM_FOR_TARGET +PATH_LOCALE +PKG_CONFIG_FOR_TARGET +PKG_CONFIG_PATH_FOR_TARGET +PYTHONHASHSEED +PYTHONNOUSERSITE +PYTHONPATH +RANLIB +RANLIB_FOR_TARGET +SIZE +SIZE_FOR_TARGET +SOURCE_DATE_EPOCH +STRINGS +STRINGS_FOR_TARGET +STRIP +STRIP_FOR_TARGET +XDG_DATA_DIRS +XML_CATALOG_FILES +__darwinAllowLocalNetworking +__impureHostDeps +__propagatedImpureHostDeps +__propagatedSandboxProfile +__sandboxProfile +__structuredAttrs +buildInputs +buildPhase +builder +cmakeFlags +configureFlags +depsBuildBuild +depsBuildBuildPropagated +depsBuildTarget +depsBuildTargetPropagated +depsHostHost +depsHostHostPropagated +depsTargetTarget +depsTargetTargetPropagated +doCheck +doInstallCheck +dontAddDisableDepTrack +mesonFlags +name +nativeBuildInputs +out +outputs +patches +phases +propagatedBuildInputs +propagatedNativeBuildInputs +shell +shellHook +stdenv +strictDeps +system ~PATH
so weird. probably my machine
$ nix --version
nix (Nix) 2.13.3
$ direnv version
2.32.2
I don't have an immediate idea. What happens when you disable direnv and run nix develop
?
Brendan Hansknecht said:
I don't have an immediate idea. What happens when you disable direnv and run
nix develop
?
running nix develop
without any direnv
interference works great (i.e. cargo build
works)
just to close the loop: though I'd seen the notices about old version of bash used in MacOS
everywhere but somehow my mind refused to follow the trail maybe because I'm using zsh?... but whatevs, I finally brew install bash
and now use flake
in my .envrc
works and is super fast :tada::face_palm:♂️
Glad you found a workaround. Direnv can definitely work with zsh in Mac, but i guess it may hit whatever issue you had. Maybe the issue is with trying to load bash config into the zsh shell...no real idea.
I'm not familiar with Cargo, is there a "clean" command I can run? Or can I just delete the target/
folder?
cargo clean
should delete all the temporary stuff, yeah
Hello, After a few tries I finally succeeded to build from source. There were warnings, but no more blocking errors. However, when I run ./target/debug/roc
, I got below message.
"Target triple (aarch64-unknown-freebsd) is not currently supported by the roc compiler."
Is FreeBSD a no-go, or did I miss something? Thank you.
Probably would be easy to support
We just don't have it in the compiler
Like probably could just be mapped to Linux or a generic Unix. I don't think anything is special about it
Noted, thank you
Last updated: Jul 05 2025 at 12:14 UTC