Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

GUI example error when using legacy linker on linux #4049

Open
Anton-4 opened this issue Sep 16, 2022 · 2 comments
Open

GUI example error when using legacy linker on linux #4049

Anton-4 opened this issue Sep 16, 2022 · 2 comments
Labels
bug Something isn't working linking

Comments

@Anton-4
Copy link
Collaborator

Anton-4 commented Sep 16, 2022

$ cargo run -- run --linker=legacy examples/gui/Hello.roc
    Finished dev [unoptimized + debuginfo] target(s) in 0.31s
     Running `target/debug/roc run --linker=legacy examples/gui/Hello.roc`
🔨 Rebuilding platform...
/nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: examples/gui/platform/host.o:(.data._rust_extern_with_linkage___dso_handle+0x0): undefined reference to `__dso_handle'
/nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: /nix/store/6f66prpgx1qx4n6k450sxs3d157ia1ps-glibc-2.35-163/lib/libc_nonshared.a(pthread_atfork.oS): in function `__pthread_atfork':
(.text+0x7): undefined reference to `__dso_handle'
/nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: examples/gui/hello-gui: hidden symbol `__dso_handle' isn't defined
/nix/store/vhf2cr6immz4qdxd83y025fnxim8mmfg-binutils-2.38/bin/ld: final link failed: bad value
1 error and 0 warnings found in 37699 ms.

Running program anyway…

────────────────────────────────────────────────────────────────────────────────
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }', crates/cli/src/lib.rs:639:61
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace```

To get around this we always used our own surgical linker instead (cargo run -- run examples/gui/Hello.roc).

This error is very similar to the one in issue #1157.

@Anton-4 Anton-4 added linking bug Something isn't working labels Sep 16, 2022
@nick-gravgaard
Copy link
Sponsor Contributor

This is strange. It looks like the helloWorld binary works when run through valgrind but not when run directly:

[nick@nick-x270 roc]$ cargo run examples/hello-world/main.roc
<lots of debug info snipped>
Segmentation fault

[nick@nick-x270 roc]$ ./examples/hello-world/helloWorld
Segmentation fault

[nick@nick-x270 roc]$ valgrind --leak-check=full --track-origins=yes ./examples/hello-world/helloWorld
==60130== Memcheck, a memory error detector
==60130== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==60130== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==60130== Command: ./examples/hello-world/helloWorld
==60130==
Hello, World!
==60130==
==60130== HEAP SUMMARY:
==60130==     in use at exit: 0 bytes in 0 blocks
==60130==   total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==60130==
==60130== All heap blocks were freed -- no leaks are possible
==60130==
==60130== For lists of detected and suppressed errors, rerun with: -s
==60130== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

(new lines added for clarity)

@Anton-4
Copy link
Collaborator Author

Anton-4 commented Jul 15, 2023

This now also happens with the surgical linker but only on aarch64 linux (raspberry pi 4, outside of nix):

---- cli_run::hello_gui stdout ----
thread 'cli_run::hello_gui' panicked at '
___________
The roc command:

  "/home/username/gitrepos/roc2/roc/target/release/roc build --optimize /home/username/gitrepos/roc2/roc/examples/gui/hello.roc --"

had unexpected stderr:

  🔨 Rebuilding platform...
ld: /home/username/gitrepos/roc2/roc/examples/gui/platform/linux-arm64.o:(.data._rust_extern_with_linkage___dso_handle+0x0): 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/username/gitrepos/roc2/roc/examples/gui/hello-gui: hidden symbol `__dso_handle' isn't defined
ld: final link failed: bad value
thread 'main' panicked at 'not yet implemented: gracefully handle `ld` (or `zig` in the case of wasm with --optimize) returning exit code Some(1)', crates/compiler/build/src/program.rs:1036:17
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working linking
Projects
None yet
Development

No branches or pull requests

2 participants