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

chore(nix): refactor, fix library packages #1080

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

jakubgs
Copy link
Contributor

@jakubgs jakubgs commented Apr 6, 2024

Bit of a cleanup to make it more readable and also fix building of libraries.

Moving the actual build to default.nix makes flake.nix more readable.

@status-im-auto
Copy link

status-im-auto commented Apr 6, 2024

Jenkins Builds

Click to see older builds (7)
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ c987810 #1 2024-04-06 11:25:51 ~11 sec nix-flake 📄log
✖️ 90ddc15 #2 2024-04-06 11:27:54 ~10 sec nix-flake 📄log
✖️ 845190b #3 2024-04-06 11:32:25 ~1 min nix-flake 📄log
✖️ 6c968d5 #4 2024-04-06 11:49:41 ~1 min nix-flake 📄log
✖️ 026364e #5 2024-04-06 12:39:16 ~1 min nix-flake 📄log
✖️ 1c5684d #6 2024-04-06 19:59:32 ~1 min nix-flake 📄log
✖️ cfba0b9 #7 2024-04-16 13:28:02 ~1 min nix-flake 📄log
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ c19ac82 #8 2024-04-16 13:32:45 ~1 min nix-flake 📄log
✖️ 81b0b92 #9 2024-06-07 10:19:06 ~38 sec nix-flake 📄log

@jakubgs jakubgs force-pushed the nix/refactor-lib branch 5 times, most recently from 026364e to 1c5684d Compare April 6, 2024 19:57
@jakubgs
Copy link
Contributor Author

jakubgs commented Apr 6, 2024

For some reason when i try to build dynamic-library I get:

> # github.com/waku-org/go-waku/library/c
> /nix/store/mzrw2zphz9xx9s3qq8x5zpf18isp0jga-go-1.20.3/share/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
> /nix/store/ybw485608d7f1yv1v071j2052q64mvla-binutils-2.40/bin/ld: /build/go-link-2631521468/go.o: relocation R_X86_64_TPOFF32 against `runtime.tlsg' can not be used when making a shared object; recompile with -fPIC
> /nix/store/ybw485608d7f1yv1v071j2052q64mvla-binutils-2.40/bin/ld: failed to set dynamic section sizes: bad value
> collect2: error: ld returned 1 exit status

It works just fine within nix develop shell using make dynamic-library.

flake.nix Outdated Show resolved Hide resolved
""")
} }
}
stage('Check') {
steps {
sh 'ldd ./result/bin/c'
sh 'ldd ./result/bin/libgowaku.a'
Copy link
Member

@richard-ramos richard-ramos Apr 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See prev comment.

@richard-ramos
Copy link
Member

@jakubgs is it possible to run go env GOGCCFLAGS right before the build is done? i run it locally and have the following:

-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build621380261=/tmp/go-build -gno-record-gcc-switches

I'm thinking this -fPIC in the GOGCCFLAGS variable might be missing in the nix build.

@richard-ramos
Copy link
Member

Or maybe doing something like this works?

env CGO_LDFLAGS=-fPIC go build etc etc etc...

Copy link

Thank you for opening this pull request!

We require pull request titles and commits to follow the Conventional Commits specification and it looks like your PR needs to be adjusted.

Details:

According to the conventional-commits specification, some of the commit messages are not valid.

@jakubgs
Copy link
Contributor Author

jakubgs commented Apr 16, 2024

I have tried applying GOGCCFLAGS = "-fPIC" in the Nix derivation, but it did not work.

I have also tried -Wl,-Bsymbolic but that did not help either. Maybe I'm applying them wrong. Pushed.

@jakubgs
Copy link
Contributor Author

jakubgs commented Apr 16, 2024

is it possible to run go env GOGCCFLAGS right before the build is done?

Yes, I can add this in the build derivation:

  preBuild = ''
    go env GOGCCFLAGS
  '';

And I can then get:

 -fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/build/go-build1875450279=/tmp/go-build -gno-record-gcc-switches

So it seems ot me like it is there, and yet it still fails with:

relocation R_X86_64_TPOFF32 against `runtime.tlsg' can not be used when making a shared object; recompile with -fPIC

Bit of a cleanup to make it more readable and also fix building of libraries.

Moving the actual build to `default.nix` makes `flake.nix` more readable.

Signed-off-by: Jakub Sokołowski <[email protected]>
```
/nix/store/mzrw2zphz9xx9s3qq8x5zpf18isp0jga-go-1.20.3/share/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/nix/store/ybw485608d7f1yv1v071j2052q64mvla-binutils-2.40/bin/ld: /build/go-link-2631521468/go.o: relocation R_X86_64_TPOFF32 against `runtime.tlsg' can not be used when making a shared object; recompile with -fPIC
/nix/store/ybw485608d7f1yv1v071j2052q64mvla-binutils-2.40/bin/ld: failed to set dynamic section sizes: bad value
collect2: error: ld returned 1 exit status
```

Signed-off-by: Jakub Sokołowski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

3 participants