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

12.13.0 build from scratch fails on RPi3 Raspian #30174

Closed
btsimonh opened this issue Oct 30, 2019 · 6 comments
Closed

12.13.0 build from scratch fails on RPi3 Raspian #30174

btsimonh opened this issue Oct 30, 2019 · 6 comments
Labels
arm Issues and PRs related to the ARM platform. build Issues and PRs related to build files or the CI.

Comments

@btsimonh
Copy link

In order to build NodeJS from scratch on raspbian, libatomic is needed in v8.gyp so that makesnapshot links.

I believe Raspian has an arm6l kernel, even thought the CPU reports as arm7l.

I also understand that arm6l is no longer built as an official binary, and that I should not expect to build without some pain :).

I am testing a change in v8.gyp:
line 796:

        # Platforms that don't have Compare-And-Swap (CAS) support need to link atomic library
        # to implement atomic memory access
        ['v8_current_cpu in ["mips", "mipsel", "mips64", "mips64el", "ppc"]', {
          'link_settings': {
            'libraries': ['-latomic', ],
          },
        }],

to

        # Platforms that don't have Compare-And-Swap (CAS) support need to link atomic library
        # to implement atomic memory access
        ['v8_current_cpu in ["mips", "mipsel", "mips64", "mips64el", "ppc", "arm"]', {
          'link_settings': {
            'libraries': ['-latomic', ],
          },
        }],

I am no expert on this, so I'm not sure that including "arm" covers too many platforms....

Compilation now continues - I will report final results in some hours (build is slow on RPi...).

Failure was when linking v8's mksnapshot.

I also note that the NodeJS makefiles also lack -latomic, and so have temporarily modified node.gyp to enable it:
line 295:

      ['(OS=="linux" or OS=="mac")', {
        'libraries': ['-latomic'],
      }],

to

      ['(OS=="linux" or OS=="mac") and llvm_version!=0', {
        'libraries': ['-latomic'],
      }],

I know this is an unsuitable mod - Advice on a better cross platform mod appreciated.

p.s. the armv7 binary runs happily on Raspbian on RPi3 - but is unlikely to work on RPiZero or Rpi1 (please correct me if I am wrong...)? There are millions of these devices out in the wild, and continued NodeJS support for them would be nice - e.g. for Node-Red use.

@af4ex
Copy link

af4ex commented Nov 2, 2019

I too was getting 'atomic' errors in building 12.13.0 on my new RPi4. I can see the libatomic runtime is installed on the system (buster), so apparently RASPIAN does use it.

But I had to do a "sudo apt install libatomic-ops-dev" to get it to link, after adding -latomic to the link settings in v8.gyp

@btsimonh
Copy link
Author

btsimonh commented Nov 2, 2019

just a note:
The resulting executable built on Raspbian Buster on RPi3 is armv6 compatible - i'm no expert, but the readelf hints at this, and it does run on RPiZero. I don't think I specifically installed libatomic dev libraries, but was building via nexe.

@gireeshpunathil
Copy link
Member

@btsimonh -does #30099 fix this issue? or only part of it?

@btsimonh
Copy link
Author

i got a shiny rpi4 for xmas which is still in the box; will see if I can get time this week to put a fresh OS on it and try a build. At least the build time should be about a 1/4 of the time compared to my RPi3...
@af4ex - are you in a position to test a build including this commit?

@btsimonh
Copy link
Author

Seems like a silly observation;
Would statically linking libatomic be a bad thing to avoid all the to-ing and fro-ing about it?

I have a hacked version of node.gyp which caused libatomic to be needed for amazon linux 2 (I copied my rpi config) - I corrected this and got a viable executable (I did not notice at first, because the build process itself installs libatomic, so testing on the platform you build on is invalid). (12.13.0)

I just tested changing
'libraries': ['-latomic'],
to
'libraries': ['-l:libatomic.a'],

and the exe no longer needs libatomic according to ldd

Am I barking up the wrong tree? Does libatomic, when compiled on a system which has the required features, just become an empty library?

@targos targos added arm Issues and PRs related to the ARM platform. build Issues and PRs related to build files or the CI. labels Dec 26, 2020
@bnoordhuis
Copy link
Member

With v12.x out of support and this issue not having seen activity in 2.5 years, I'll go ahead and close it out.

@bnoordhuis bnoordhuis closed this as not planned Won't fix, can't repro, duplicate, stale Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arm Issues and PRs related to the ARM platform. build Issues and PRs related to build files or the CI.
Projects
None yet
Development

No branches or pull requests

5 participants