guiHua
2022-Oct-20 16:10 UTC
[Libguestfs] Why cant't use the pie link option when compiling libgustfs
Hello? When I compile libgustfs, it will throw exception: undefined reference to 'caml_local_roots' when adding pie link option. Why is that? The command is like this: ./configure CFLAGS="-O2 -fPIC" LDFLAGS="-pie -Wl". I look forward to hearing from you. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://listman.redhat.com/archives/libguestfs/attachments/20221021/d86f661b/attachment.htm>
Richard W.M. Jones
2022-Oct-20 17:12 UTC
[Libguestfs] Why cant't use the pie link option when compiling libgustfs
On Fri, Oct 21, 2022 at 12:10:43AM +0800, guiHua wrote:> Hello > When I compile libgustfs, it will throw exception: undefined reference to > 'caml_local_roots' when adding pie link option. > Why is that? The command is like this: > ./configure CFLAGS="-O2 -fPIC" LDFLAGS="-pie -Wl".Is that LDFLAGS actually valid? You might try putting -pie into CFLAGS, and I don't know if -Wl has any effect at all.> I look forward to hearing from you.I'm not certain why, but I can tell you that caml_local_roots is a symbol in the OCaml runtime: $ cat > hello.ml print_endline "hello, world" $ ocamlopt hello.ml -o hello $ ./hello hello, world $ nm hello | grep caml_local_roots 0000000000000024 a domain_field_caml_local_roots It's actually defined here: https://github.com/ocaml/ocaml/blob/trunk/runtime/caml/memory.h#L238 (The "domain_field_" prefix is something to do with multicore, it used to be a global variable, but now is stored per-thread.) What distro is this? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW