FS#42748 - [ocaml] Build with PIE/PIC (hardening-wrapper).
Attached to Project:
Arch Linux
Opened by Earnestly (Earnest) - Tuesday, 11 November 2014, 18:24 GMT
Last edited by Jürgen Hötzel (juergen) - Friday, 14 July 2017, 16:45 GMT
Opened by Earnestly (Earnest) - Tuesday, 11 November 2014, 18:24 GMT
Last edited by Jürgen Hötzel (juergen) - Friday, 14 July 2017, 16:45 GMT
|
Details
I cannot build an Ocaml project with Arch's ocaml package
because it doesn't support relocation.
ocamlopt -o llpp -g -w +a-4 -I +lablGL link.o -cclib '-Wl,-O1,--sort-common,--as-needed,-z,relro -g -L/usr/lib -lX11 -lpthread -lmupdf -lmujs -ljbig2dec -lcrypto -lz -lopenjp2 -ljpeg -lfreetype' unix.cmxa str.cmxa lablgl.cmxa bo.cmx help.cmx utils.cmx wsi.cmx parser.cmx config.cmx main.cmx /usr/bin/ld: /usr/lib/ocaml/libasmrun.a(startup.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC /usr/lib/ocaml/libasmrun.a: error adding symbols: Bad value collect2: error: ld returned 1 exit status File "caml_startup", line 1: Error: Error during linking /home/earnest/build/pkgbuilds/llpp-git/src/Makefile:32: recipe for target 'llpp' failed make: *** [llpp] Error 2 I have solved this by maintaining my own ocaml package which is built with PIC/RELOC, i.e. the hardening-wrapper. |
This task depends upon
Solution: got the PKGBUILD, modified the ./configure:
./configure -prefix /usr -x11include /usr/include -cc "gcc -fPIC" -aspp "gcc -fPIC -c"
Now I can compile proverif, cryptoverif from aur.
Rebuilding ocaml with `-cc "gcc -fPIC" -aspp "gcc -fPIC -c"` works but feels like using a sledgehammer to kill a fly.
I did not found the place to add `-runtime-variant _pic` in ocaml-sqlite3 but adding it to the failed command and rerunning it manually in src/ works too.
Any final decision on this ?
There seems to be three options :
1/ Compile ocaml with -fPIC or
2/ Explain how to use `-runtime-variant _pic` in scilab, proverif, cryptoverif, ocaml-sqlite3 or
4/ Make ocaml autodetect the need for hared libraries or
3/ Discover that it works out of the box and I am the only guy with a broken config :-).
@tpowa ?
[1] http://caml.inria.fr/mantis/view.php?id=6693
See https://aur.archlinux.org/packages/opam/?comments=all
see https://github.com/ocaml/ocaml/blob/trunk/configure#L211