[haiku-development] Re: /usr/local/bin/ld: cannot find -ldl , what is this?

  • From: "Thomas Mueller" <mueller6723@xxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • To: Haiku Development ML <haiku-development@xxxxxxxxxxxxx>
  • Date: Wed, 05 Jun 2019 19:46:52 +0000

June 4, 2019 11:30 PM, "Thomas Mueller" <mueller6723@xxxxxxx> wrote:

I am again trying to cross-compile Haiku (master branch) from FreeBSD, but 
the build (jam -q
@anyboot-image, or jam -q @nightly-anyboot) quickly fails. What is -ldl?

Past attempts didn't fail so quickly or for this reason.

This is for amd64. Configure script for x86-gcc2 hybrid consistency failed 
apparently because of
something incompatible in the gcc2 part:

collect2: error: ld returned 1 exit status
*** The command 'gcc -m32 -o conftest -O2 -U_FORTIFY_SOURCE conftest.c' 
failed.
*** You must set the environment variable CC to a working compiler.

What does that mean? I set CC to the path to gcc.

 
It means people don't build on FreeBSD enough :-)
        
Try this:
 
diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup
index 076a14879b..0fcfc6bd2c 100644
--- a/build/jam/BuildSetup
+++ b/build/jam/BuildSetup
@@ -398,7 +398,10 @@ if $(HOST_PLATFORM_HAIKU_COMPATIBLE) {
        HOST_CCFLAGS += $(compatibilityHeader) ;
        HOST_C++FLAGS += $(compatibilityHeader) ;
 } else {
-       HOST_LINKFLAGS += -lm -ldl ;
+       HOST_LINKFLAGS += -lm ;
+       if $(HOST_PLATFPRM) != freebsd {
+               HOST_LINKFLAGS += -ldl ;
+       }
        HOST_LIBSTDC++ = stdc++ ;
        if $(HOST_PLATFORM) = mingw {
                HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR


We call -ldl for dlopen and other functions with the host tools,
and these seem to exist within libc on FreeBSD

Thanks!

  Alexander von Gluck IV

I believe cross-compiling support on FreeBSD has bitrotted from lack of use.  
There is even a reference to FreeBSD 8 in haiku/jam/BuildSetup.  FreeBSD 8 is 
long past end-of-life.

I just made the changes to BuildSetup and will see how/if it goes.  But I 
wonder why this didn't bite me long before my attempt of last April 21-22.

from Richard Zak:

-ldl is for libdl, and it's a "Linuxism" according to:
https://forums.freebsd.org/threads/usr-bin-ld-cannot-find-ldl.5799/
As for getting Jam to build on FreeBSD, that'll likely take some time and
effort to figure out how to replace libdl, and using Linux would be faster,
I think.

Type of error made me wonder if the cross-build system was messed up and would 
not work even on Linux.

But a lot of things seem to work better on Linux than on FreeBSD or NetBSD.  
Now I seem unable to access the internet from the newer FreeBSD 12-STABLE and 
HEAD, raising big doubts about my future with FreeBSD.

I also wonder what prevents building the cross-tools for x86_gcc2 and x86 
hybrid from FreeBSD, and if Linux would do better. 

 collect2: error: ld returned 1 exit status
 *** The command 'gcc -m32 -o conftest -O2 -U_FORTIFY_SOURCE conftest.c' failed.
 *** You must set the environment variable CC to a working compiler.

Before sending this message, I tried again with the revisions to BuildSetup, 
got the same error:

Starting build of type regular ... 
Skipping setjmp_test2.S test on non-x86 
...patience...
don't know how to make 
/home/arlene/haiku/fb64generated.amd64.gcc6aux/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/8.3.0/../../../../x86_64-unknown-haiku/lib/32/libsupc++.a
don't know how to make 
/home/arlene/haiku/fb64generated.amd64.gcc6aux/cross-tools-x86_64/lib/gcc/x86_64-unknown-haiku/8.3.0/32/libgcc.a
don't know how to make <x86_64>crtbeginS.o
don't know how to make <x86_64>crtendS.o
...patience...
...patience...
...patience...
...patience...
...patience...
...patience...
...patience...
...patience...
...patience...
...patience...
...found 100811 target(s)...
...updating 13293 target(s)...
...can't find 4 target(s)...
...can't make 1633 target(s)...
C++ objects/freebsd/x86_64/release/tools/anyboot/anyboot.o 
Link objects/freebsd/x86_64/release/tools/anyboot/anyboot 
/usr/local/bin/ld: cannot find -ldl
collect2: error: ld returned 1 exit status

export 
"LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/arlene/haiku/fb64generated.amd64.gcc6aux/objects/freebsd/lib"
 ; ../haiku/build/scripts/rm_attrs 
objects/freebsd/x86_64/release/tools/rm_attrs -f 
"objects/freebsd/x86_64/release/tools/anyboot/anyboot"
/usr/local/gcc6-aux/bin/gcc -Xlinker --no-as-needed -lm -ldl -L/usr/local/lib 
-lz -o "objects/freebsd/x86_64/release/tools/anyboot/anyboot"   
"objects/freebsd/x86_64/release/tools/anyboot/anyboot.o" \
 -lstdc++  \


...failed Link objects/freebsd/x86_64/release/tools/anyboot/anyboot ...



Tom


Other related posts: