Skip to content
This repository has been archived by the owner on Sep 9, 2020. It is now read-only.

prebuilt release for gcc 4.8 #10

Closed
cyjake opened this issue Nov 25, 2019 · 26 comments
Closed

prebuilt release for gcc 4.8 #10

cyjake opened this issue Nov 25, 2019 · 26 comments
Assignees

Comments

@cyjake
Copy link

cyjake commented Nov 25, 2019

https://docs.travis-ci.com/user/languages/cpp/#gcc-on-linux

Is it ok to provide prebuilt release for linux environments that use gcc 4.8 as well? I've tested compiling node-swc on one of our linux box and it works as expected with gcc 4.8

cc @fengmk2

@cyjake
Copy link
Author

cyjake commented Nov 25, 2019

@kdy1 Can you send me (leto.zju#hotmail.com) an invitation of https://swc-org.slack.com/ ?

@kdy1
Copy link
Member

kdy1 commented Nov 25, 2019

@cyjake https://swc-slackin.herokuapp.com/
swc provides prebuilt binary built with rustc, not clang. What does you mean by "use gcc 4.8"?

@kdy1
Copy link
Member

kdy1 commented Nov 25, 2019

@cyjake Btw, please feel free to ping me on github or slack if you need any help using swc.

@cyjake
Copy link
Author

cyjake commented Nov 25, 2019

@kdy1 I believe the linux environment that runs rustc is default to gcc 5.4 https://github.com/swc-project/node-swc/blob/master/.travis.yml#L76 hence make the linked binary demanding cxxabi_1.3.9 (which is the abi version provided by gcc 5)

@kdy1
Copy link
Member

kdy1 commented Nov 25, 2019

@cyjake I got it. I'll publish a new version asap.

@kdy1 kdy1 self-assigned this Nov 25, 2019
@kdy1
Copy link
Member

kdy1 commented Nov 25, 2019

@cyjake I published v1.0.54.
Can you check if the issue is solved?

@cyjake
Copy link
Author

cyjake commented Nov 25, 2019

nope. I'll investigate

@kdy1
Copy link
Member

kdy1 commented Nov 25, 2019

@cyjake Although it's a rough guess, maybe an envrionment variable CC=gcc-4.8 is required

@cyjake
Copy link
Author

cyjake commented Nov 25, 2019

@kdy1 Yeah, I was composing a comment about the same suspect :-)

@kdy1
Copy link
Member

kdy1 commented Nov 25, 2019

@cyjake I configured CC and CXX.

Can you check it? I don't have a linux machine.

Steps

  1. Download appropriate version of binary from

https://github.com/swc-project/node-swc/releases/tag/v1.0.55

57 is for node@8, 64 is for node@10, 67 is for node@11 and 72 is for node@12.

  1. git clone [email protected]:swc-project/node-swc.git

  2. cd node-swc

  3. Rename file downloaded on step 1 to native/index.node

  4. Run jest __tests__/import_test.js

@kdy1
Copy link
Member

kdy1 commented Nov 25, 2019

@cyjake If you are busy, I can test it tomorrow.

@cyjake
Copy link
Author

cyjake commented Nov 26, 2019

I tried with https://github.com/swc-project/node-swc/releases/download/v1.0.55/linux-x64-64.node

> require('./lib/index')
Thrown:
Error: /root/foo/node-swc/native/index.node: invalid ELF header
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
> process.version
'v10.16.3'

Now that's something new... false alarm, I was trying with incomplete binary data.

@cyjake
Copy link
Author

cyjake commented Nov 26, 2019

> require('./lib/index')
Thrown:
Error: /lib64/libc.so.6: version `GLIBC_2.18' not found (required by /home/admin/node-swc/native/index.node)
    at Object.Module._extensions..node (internal/modules/cjs/loader.js:807:18)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)

It works but out system uses glibc 2.17. Which version of gcc was used to compile, 4.8 or 4.9?

@kdy1
Copy link
Member

kdy1 commented Nov 26, 2019

I think gcc 4.8 is used.

node-swc/.travis.yml

Lines 4 to 10 in b7ebded

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- gcc-4.8
- g++-4.8

export CC=gcc-4.8
export CXX=g++-4.8


But I'm not sure and I'll investigate further.

@cyjake
Copy link
Author

cyjake commented Nov 26, 2019

I think gcc and glibc versions aren't that correlated https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Linux_compatibility_matrix

It seems I have to provide a specific prebuilt package for our environment by myself. There're just too many gcc glibc versions to support if all of them needs to be supported by you.

@kdy1
Copy link
Member

kdy1 commented Nov 26, 2019

Oh.. It is much more complicated than I thought.

I guess using musl-libc can solve the issue. Do you mind it?

@cyjake
Copy link
Author

cyjake commented Nov 26, 2019

It could be. But preparing another package for our linux infrastructure is another pain (there's no musl package yet) I'd rather not go through. I've tried and succeeded to build node-swc on my local docker container with default gcc and glibc settings, hence I think I should go with a slightly forked mirror.

@kdy1
Copy link
Member

kdy1 commented Nov 26, 2019

Hmm.. Despite of the linux compatibility table, many linux binary work without any issue. (especially programs written in golang)

Clearly, there's a way to support multiple glibc version with single binary.

I'll investigate further when I go home. I don't have a linux machine now.

And if possible, I want to avoid the situation where user rebuilt swc on their machine because building swc takes long time.

@cyjake
Copy link
Author

cyjake commented Nov 26, 2019

Agree and much appreciated. It could still work If we can build with gcc 4.8 and glibc 2.17. I'm trying to find ways to accomplish that.

@kdy1
Copy link
Member

kdy1 commented Nov 26, 2019

@cyjake I've investigated, but I failed. I'll investigate further.
There's a simple solution, but I need more information.

I configured docker based build system on travis, so I can easily change version of the linked glibc. I guess you are using centos 7, right? I'll try it.

Investigations

(for who tries to do simillar thing)

  • proc macro crates requires dynamic linking.
    • Works without any problem with linux-gnu target

    • Requires -C target-feature=-crt-static on musl target
      As this flags is also passed to non-proc macro crates, this disables static linking of libc and musl-libc.so is required on runtime.

Related: neon-bindings/neon#360 (comment)


  • rust uses feature from GLIBC_2.18

Related: rust-lang/rust#57497. But linkage is weak, so we can build it with older version of glibc.


  • linux-musl target does not support crate-type = cdylib

According to https://github.com/wangbj/rust-staticlib-linker, I can do it but it will crash because nodejs uses glibc,

@cyjake
Copy link
Author

cyjake commented Nov 27, 2019

Great findings! yes we're using centos 7.

@cyjake
Copy link
Author

cyjake commented Nov 27, 2019

Guess we can use travis docker service with the centos image from docker hub.

@kdy1
Copy link
Member

kdy1 commented Nov 27, 2019

There's prebuilt binaries built on centos 7. Can you test it?

https://github.com/swc-project/node-swc/releases/tag/v1.0.55

I verified that it works with newer version of glibc (ubuntu 18.04, all updated).

@kdy1
Copy link
Member

kdy1 commented Nov 28, 2019

There's a validation script which successed to run on centos 7. Closing.

@kdy1 kdy1 closed this as completed Nov 28, 2019
@kdy1
Copy link
Member

kdy1 commented Nov 28, 2019

I've published v1.0.55

@cyjake
Copy link
Author

cyjake commented Nov 28, 2019

@kdy1 It works perfectly both on my local docker container and our ci environment. Hooray!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants