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

nodejs-13.7.0 fails with ld.gold linker #31520

Closed
drwulsen opened this issue Jan 26, 2020 · 4 comments
Closed

nodejs-13.7.0 fails with ld.gold linker #31520

drwulsen opened this issue Jan 26, 2020 · 4 comments
Labels
build Issues and PRs related to build files or the CI.

Comments

@drwulsen
Copy link

drwulsen commented Jan 26, 2020

  • 13.7.0:
  • Linux:

linking fails with ld.gold (binutils-2.33.1) in this way:

/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/net-libs/nodejs-13.7.0-r1/work/node-v13.7.0/src/large_pages/ld.implicit.script:10:10: syntax error, unexpected STRING
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: fatal error: unable to parse script file /var/tmp/portage/net-libs/nodejs-13.7.0-r1/work/node-v13.7.0/src/large_pages/ld.implicit.script
collect2: error: ld returned 1 exit status
make: *** [cctest.target.mk:195: /var/tmp/portage/net-libs/nodejs-13.7.0-r1/work/node-v13.7.0/out/Release/cctest] Error 1
make: *** Waiting for unfinished jobs....
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: error: /var/tmp/portage/net-libs/nodejs-13.7.0-r1/work/node-v13.7.0/src/large_pages/ld.implicit.script:10:10: syntax error, unexpected STRING
/usr/lib/gcc/x86_64-pc-linux-gnu/9.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: fatal error: unable to parse script file /var/tmp/portage/net-libs/nodejs-13.7.0-r1/work/node-v13.7.0/src/large_pages/ld.implicit.script
collect2: error: ld returned 1 exit status
make: *** [mkcodecache.target.mk:172: /var/tmp/portage/net-libs/nodejs-13.7.0-r1/work/node-v13.7.0/out/Release/mkcodecache] Error 1

switching to ld.bfd yields in a error-less compilation and installation on gentoo.
Forcing the ld.bfd linker was done by prepending LDFLAGS="${LDFLAGS} -Wl,-fuse-ld=bfd" to the emerge command.

Searching around I found this:
https://lists.gnu.org/archive/html/bug-binutils/2016-12/msg00035.html
https://bugzilla.redhat.com/show_bug.cgi?id=927573
https://sourceware.org/bugzilla/show_bug.cgi?id=15373
Which says that ld.gold does not support the Insert statement in linker scripts.

If you want me to test something, please feel free to do so.

@richardlau richardlau added the build Issues and PRs related to build files or the CI. label Jan 26, 2020
@richardlau
Copy link
Member

Similar to #31249.

@bnoordhuis
Copy link
Member

It's not quite the same as #31249, although you'll get the same link errors when you remove the INSERT BEFORE line from the linker script. ^^

I don't have time to look into it today but we probably don't need the linker script if we switch to the __executable_start symbol provided by LLVM's and GNU ld's default linker script; run ld --verbose to view it.

Caveat emptor: they're not completely interchangeable because there are a number of sections in between. __executable_start is about 8 MB below __nodetext so some code tweaking is necessary.

bnoordhuis added a commit to bnoordhuis/io.js that referenced this issue Jan 28, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520
@bnoordhuis
Copy link
Member

@drwulsen Can you try #31547?

@drwulsen
Copy link
Author

drwulsen commented Feb 8, 2020

@drwulsen Can you try #31547?

Sorry for the (too) late reply; just tested and it compiled as I hoped for.
Thank you for the quick steps taken!

codebytere pushed a commit that referenced this issue Feb 17, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: #31520

PR-URL: #31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue Mar 6, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520

PR-URL: nodejs#31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
gabrielschulhof pushed a commit to gabrielschulhof/node that referenced this issue Apr 9, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520

PR-URL: nodejs#31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit to targos/node that referenced this issue Apr 25, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: nodejs#31520

Backport-PR-URL: nodejs#32092
PR-URL: nodejs#31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
targos pushed a commit that referenced this issue Apr 28, 2020
`__executable_start` is provided by GNU's and LLVM's default linker
scripts, obviating the need to plug in a custom linker script.

The problem with our bespoke linker script is that it works with ld.bfd
but not ld.gold and cannot easily be ported because the latter linker
doesn't understand the `INSERT BEFORE` directive.

The /proc/self/maps scanner is updated to account for the fact that
there are a number of sections between `&__executable_start` and
the start of the .text section.

Fortunately, those sections are all mapped into the same memory segment
so we only need to look at the next line to find the start of our text
segment.

Fixes: #31520

Backport-PR-URL: #32092
PR-URL: #31547
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues and PRs related to build files or the CI.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants