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

Avoiding hardcoded build options #133

Open
artemp opened this issue May 3, 2018 · 3 comments
Open

Avoiding hardcoded build options #133

artemp opened this issue May 3, 2018 · 3 comments

Comments

@artemp
Copy link
Contributor

artemp commented May 3, 2018

Currently in order to build on Ubuntu Linux (18.04) using either system g++7 or source compiled clang++7 I had to apply following patch:

CXX=/usr/bin/g++ make
diff --git a/common.gypi b/common.gypi
index 803f217..6ae5c84 100644
--- a/common.gypi
+++ b/common.gypi
@@ -38,11 +38,8 @@
           'NDEBUG'
         ],
         'cflags': [
-         '-flto'
         ],
         'ldflags': [
-         '-flto',
-         '-fuse-ld=<(module_root_dir)/mason_packages/.link/bin/ld'
         ],
         'xcode_settings': {
           'OTHER_CPLUSPLUSFLAGS!': [
@springmeyer
Copy link
Contributor

springmeyer commented May 3, 2018

@artemp thanks for creating this / catching the problem. I thought I tested well enough on linux, but I must have missed something. LTO, in my experience, is hard to get working on linux, so I'm open to reverting this change and having LTO be opt-in rather than opt-out.

But, before reverting I'm interested in what the exact errors you are seeing with CXX=/usr/bin/g++ make before removing LTO? Also (again with the -flto still in place) what happens if you try:

CXX=/usr/bin/g++ LINK=/usr/bin/g++ make

or

CXX=/usr/bin/g++ LINK=/usr/bin/g++ AR="gcc-ar" NM="gcc-nm" RANLIB="gcc-ranlib" make

Refs:

@artemp
Copy link
Contributor Author

artemp commented May 3, 2018

CXX=clang++ make

/home/artem/projects/node-cpp-skel/mason_packages/.link/bin/clang++ -shared -pthread -rdynamic -m64 -Wl,-z,now -flto -flto  -Wl,-soname=module.node -o /home/artem/projects/node-cpp-skel/lib/binding/module.node -Wl,--start-group Release/obj.target/module/src/module.o Release/obj.target/module/src/standalone/hello.o Release/obj.target/module/src/standalone_async/hello_async.o Release/obj.target/module/src/object_sync/hello.o Release/obj.target/module/src/object_async/hello_async.o -Wl,--end-group 
Intrinsic has incorrect argument type!
void (i8*, i8*, i64, i1)* @llvm.memcpy.p0i8.p0i8.i64
LLVM ERROR: Broken function found, compilation aborted!

CXX=g++ make

/home/artem/projects/node-cpp-skel/mason_packages/.link/bin/ld: Release/obj.target/module/src/module.o: plugin needed to handle lto object
/home/artem/projects/node-cpp-skel/mason_packages/.link/bin/ld: Release/obj.target/module/src/standalone/hello.o: plugin needed to handle lto object
/home/artem/projects/node-cpp-skel/mason_packages/.link/bin/ld: Release/obj.target/module/src/standalone_async/hello_async.o: plugin needed to handle lto object
/home/artem/projects/node-cpp-skel/mason_packages/.link/bin/ld: Release/obj.target/module/src/object_sync/hello.o: plugin needed to handle lto object
/home/artem/projects/node-cpp-skel/mason_packages/.link/bin/ld: Release/obj.target/module/src/object_async/hello_async.o: plugin needed to handle lto object
  rm -rf "Release/module.node" && cp -af "/home/artem/projects/node-cpp-skel/lib/binding/module.node" "Release/module.node"
make[1]: Leaving directory '/home/artem/projects/node-cpp-skel/build'

@artemp
Copy link
Contributor Author

artemp commented May 3, 2018

CXX=/usr/bin/g++ LINK=/usr/bin/g++ make

works!

CXX=/usr/bin/clang++ LINK=/usr/bin/clang make

/usr/bin/ld: /opt/llvm/bin/../lib/LLVMgold.so: error loading plugin: /opt/llvm/bin/../lib/LLVMgold.so: cannot open shared object file: No such file or directory
clang-7.0: error: linker command failed with exit code 1 (use -v to see invocation)
module.target.mk:167: recipe for target '/home/artem/projects/node-cpp-skel/lib/binding/module.node' failed
make[1]: *** [/home/artem/projects/node-cpp-skel/lib/binding/module.node] Error 1
make[1]: Leaving directory '/home/artem/projects/node-cpp-skel/build'

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

No branches or pull requests

2 participants