bsansouci / bsb-native

Build system for OCaml/Reason
Other
245 stars 10 forks source link

I tried to run a project with bsb native on ubuntu and got this #35

Closed mrkaspa closed 6 years ago

mrkaspa commented 6 years ago

This is te project https://github.com/jaredly/minimist.re, when running the output is:

yarn run build                                                                                  
yarn run v1.3.2                                                                                                               
$ bsb -make-world -backend native                                                                                             
ninja: Entering directory `lib/bs/native'                                                                                     
[4/4] Building src/Minimist.mlast.d                                                                                           
[3/3] Building test.native                                                                                                    
FAILED: test.native                                                                                                           
/home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/lib/bsb_helper.exe -add-ocaml-dependency bigarray -add-ocaml-depend
ency dynlink -add-ocaml-dependency nums -add-ocaml-dependency str -add-ocaml-dependency threads -add-ocaml-dependency unix -w 
-30-40+6+7+27+32..39+44+45+101-40+6+7-26-27+32..39-28-44+45 -warn-error +8  -bs-main Test -bs-super-errors    src/Minimist.mla
st test/Test.mlast -link-native test.native                                                                                   
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(startup.o): relocat
ion R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                    
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(fail.o): relocation
 R_X86_64_32 against symbol `caml_exn_Failure' can not be used when making a shared object; recompile with -fPIC              
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(roots.o): relocatio
n R_X86_64_32S against symbol `caml_frametable' can not be used when making a shared object; recompile with -fPIC             
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(globroots.o): reloc
ation R_X86_64_32 against symbol `caml_global_roots' can not be used when making a shared object; recompile with -fPIC        
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(signals.o): relocat
ion R_X86_64_32S against undefined symbol `caml_pending_signals' can not be used when making a shared object; recompile with -
fPIC                                                                                                                          
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(signals_asm.o): rel
ocation R_X86_64_32S against symbol `caml_system__code_begin' can not be used when making a shared object; recompile with -fPI
C                                                                                                                             
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(freelist.o): reloca
tion R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC                            
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(major_gc.o): reloca
tion R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC                   
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(minor_gc.o): reloca
tion R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                   
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(memory.o): relocati
on R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC                     
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(alloc.o): relocatio
n R_X86_64_32S against undefined symbol `caml_atom_table' can not be used when making a shared object; recompile with -fPIC   
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(compare.o): relocat
ion R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC                             
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(ints.o): relocation
 R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(floats.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                     
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(str.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                        
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(array.o): relocation R_X86_64_32 against undefined symbol `caml_atom_table' can not be used when making a shared object; recompile with -fPIC    
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(io.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC                                  
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(extern.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC                              
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(intern.o): relocation R_X86_64_32S against undefined symbol `caml_atom_table' can not be used when making a shared object; recompile with -fPIC  
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(hash.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC                             
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(sys.o): relocation R_X86_64_32 against `.data' can not be used when making a shared object; recompile with -fPIC                                 
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(parsing.o): relocation R_X86_64_32S against `.rodata' can not be used when making a shared object; recompile with -fPIC                          
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(gc_ctrl.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC                    
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(obj.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC                        
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(printexc.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                   
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(callback.o): relocation R_X86_64_32S against `.bss' can not be used when making a shared object; recompile with -fPIC                            
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(weak.o): relocation R_X86_64_32 against symbol `caml_weak_ref_table' can not be used when making a shared object; recompile with -fPIC           
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(compact.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                    
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(finalise.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                   
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(custom.o): relocation R_X86_64_32S against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                    
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(unix.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC                       
/usr/bin/ld: /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/libasmrun.a(backtrace.o): relocation R_X86_64_32 against symbol `caml_backtrace_last_exn' can not be used when making a shared object; recompile with -fPIC  
/usr/bin/ld: final link failed: Nonrepresentable section on output                                                            
collect2: error: ld returned 1 exit status                     

  We've found a bug for you!   
  caml_startup                 

  Error during linking         

ninja: build stopped: subcommand failed.                       
error Command failed with exit code 2.                         
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.  
bsansouci commented 6 years ago

cc @Schmavery who did the binary build on linux.

Just to make sure, are you using the release bsansouci/bsb-native#2.1.1? Could you try master? Master should work, just take a little longer because it'll build a local version of ocaml for you etc...

Could you paste the full error or is it too long?

mrkaspa commented 6 years ago

@bsansouci done, my dependency is

"devDependencies": {
    "bs-platform": "bsansouci/bsb-native#2.1.1"
  }
Schmavery commented 6 years ago

Interesting, thanks for the bug report. I'll see what I can do to reproduce this as soon as I can. Maybe -fPIC is somehow getting disabled in the configure script by my linux build environment. Would be great if we can confirm that master (no prebuilt binaries) works properly.

mrkaspa commented 6 years ago

@Schmavery I put master like this and didn't worked

"devDependencies": {
    "bs-platform": "bsansouci/bsb-native#master"
  }
bsansouci commented 6 years ago

Aah sorry for master simply put bsansouci/bsb-native

mrkaspa commented 6 years ago

@bsansouci running with that got this

 yarn run build
yarn run v1.3.2
$ bsb -make-world -backend native
ninja: Entering directory `lib/bs/native'
[4/4] Building src/Minimist.mlast.d
[3/3] Building test.native
FAILED: test.native 
/home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/lib/bsb_helper.exe -add-ocaml-dependency bigarray -add-ocaml-dependency compiler-libs -add-ocaml-dependency threads -add-ocaml-dependency unix -w -30-40+6+7+27+32..39+44+45+101-40+6+7-26-27+32..39-28-44+45 -warn-error +8  -bs-main Test -bs-super-errors    src/Minimist.mlast test/Test.mlast -link-native test.native

  We've found a bug for you!
  (No file name)

  Cannot find file /home/mrkaspa/code/ml/minimist.re/node_modules/bs-platform/vendor/ocaml/lib/ocaml/compiler-libs/ocamlcommon.cmxa

ninja: build stopped: subcommand failed.
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

That folder is not present on the node_modules

Schmavery commented 6 years ago

Hey @mrkaspa, I tried to repro this on two linux machine (one ubuntu) and couldn't get your error. Can we go over your system specs and repro steps? What version of ubuntu are you running? Do you have anything else related to ocaml installed globally, like reason-cli or opam? That shouldn't be a problem but it's good to cover our bases. What's your yarn version?

I'm assuming you're doing

git clone https://github.com/jaredly/minimist.re.git
cd minimist.re
yarn
yarn run build

and getting the first error you posted. If that is wrong please provide corrections so that I can try it.

When building the master branch, what error are you getting (during the yarn install)?

Schmavery commented 6 years ago

I just double-checked and the configure script should be including -fPIC already so I'm a bit confused here.

bsansouci commented 6 years ago

Hey is this still happening?

bsansouci commented 6 years ago

ping :)

Schmavery commented 6 years ago

I'm wondering if this could be related to https://caml.inria.fr/mantis/view.php?id=7595. Seems the closest I've been able to find so far. Edit: also potentially related: https://github.com/phusion/holy-build-box/issues/1

As it hints at in the hbb issue, I believe we need to be using a different activation for hbb to be able to build these libraries: https://github.com/phusion/holy-build-box/blob/c0bee9d92f88c2175777b86ac2ed0f7b077c315e/LIBRARY-VARIANTS.md#shlib

Hopefully after converting to shlib/activate instead of hbb/activate this problem will go away :)

Schmavery commented 6 years ago

@mrkaspa @mciparelli I just tried to rebuild the linux binary with fPIC enabled. Unfortunately I can't repro this issue on any of my machine, can either of you try to reinstall and see if it helps?

mciparelli commented 6 years ago

it took me a while to notice that bsb-native uses an own version of OCaml. I understand this issue should be no longer happening in 4.03.0 but I couldn't make this library to use the locally installed library instead of the one that comes with the repo. So I forked and recompiled with -cc "gcc -fPIC" -aspp "gcc -c -fPIC" and now it worked. It would be great to be able to use the locally installed version of ocaml somehow.

Schmavery commented 6 years ago

Great to hear you got yourself unblocked. If there's any chance someone with this problem can try again to see if my fix helped, that would be great :)

bsansouci commented 6 years ago

@mciparelli I'm confused. Which library are you talking about? If you're using bsb-native, we compile your entire project and its deps using the vendored ocaml. @Schmavery pushed a fix to the linux release that compiles all of bsb-native with its ocaml in a relocatable way, so that should fix your issue.

mciparelli commented 6 years ago

I've been pointing to the master branch of this repo and I had to add the mentioned flags to buildocaml.sh file for it to work. Which one you recommend me to use? Is there an npm package or something?

Schmavery commented 6 years ago

@mciparelli bsansouci/bsb-native#2.1.1 is the branch of the repo that attempts to install a prebuilt binary suitable for your platform. It's faster than installing master so we're trying to recommend that one and make sure it's stable for everyone.

mciparelli commented 6 years ago

I still get the following error when trying to use #2.1.1

relocation R_X86_64_32 against symbol `caml_backtrace_last_exn' can not be used when making a shared object; recompile with -fPIC

Looks like my linux version asks for the binary to be compiled with -fPIC option.

Schmavery commented 6 years ago

Darn it, thanks for sticking with us and checking! I'll try to compile a version with your -cc "gcc -fPIC" -aspp "gcc -c -fPIC" option and hopefully that fixes it.

Schmavery commented 6 years ago

@mciparelli sorry about the delay, I just tried to rebuild with these options so if you get a chance, feel free to try it again :)

mciparelli commented 6 years ago

Yeap, that rebuild made it work for me on #2.1.1

Schmavery commented 6 years ago

Awesome! Thanks so much for trying again and feel free to open more issues if you run into problems :)