Re: Pike on OpenBSD

Henrik Grubbström <[email protected]>
Newsgroups gmane.comp.lang.pike.user
Organization Roxen Internet Software AB
Message-ID <[email protected]>
On Tue, 3 Jan 2017, Bernd Schoeller wrote:

> On 03/01/17 09:14, Henrik Grubbström wrote:
>>  Ah, the configure output explains it;
>> 
>> >  checking SO... so
>> >  checking LDSHARED... gcc -Wl,-Bshareable
>> >  checking CCSHARED... checking -fPIC... yes
>> >  -fPIC
>> >  checking LINKFORSHARED... -Wl,-E
>> >  checking -static-libgcc... yes
>> >  checking if dynamic loading works... no
>>                                         ^^
>>
>>  So for some reason dlopen() et al don't work as intended, and thus
>>  you get a pike with only static modules, which means that the main
>>  pike binary won't get compiled until after post_modules.
>>
>>  /home/schoelle/Code/Pike-v8.0.388/build/openbsd-6.0-amd64/config.log
>>  should give a hint about why dlopen() failed.
>
> Ok - that explains it:
>
> configure: 68713: checking for dlopen in -ldl
> configure: 68738: 
> /home/schoelle/Code/Pike-v8.0.388/build/openbsd-6.0-amd64/smartlink gcc -o 
> conftest -g  -fvisibility=hidden -O3 -pipe -ggdb -funswitch-loops 
> -I/usr/local/include -I/usr/X11R6/include 
> -I/home/schoelle/Code/Pike-v8.0.388/src 
> -I/home/schoelle/Code/Pike-v8.0.388/build/openbsd-6.0-amd64 -L/usr/local/lib 
> -R/usr/local/lib -L/usr/X11R6/lib -R/usr/X11R6/lib 
> -L/usr/lib/gcc-lib/amd64-unknown-openbsd6.0/4.2.1 conftest.c -ldl  -lm  >&5
> /usr/bin/ld: cannot find -ldl
> collect2: ld returned 1 exit status

The above is expected and is just a test to see if -ldl is required.

You need to look further down in the config.log.

> Looks like -ldl is not needed on OpenBSD. The functions are available as 
> documented here:
>
> http://man.openbsd.org/OpenBSD-current/man3/dlfcn.3
>
> I have removed the inclusion of -ldl into LIBS in the configure script.
>
> Now, things are very messy with lots of errors. Will continue to dig further.
>
> Current output is here:
>
> https: //www.fams.de/bernte/gmake-out2.txt
> https: //www.fams.de/bernte/config.log.txt

From config.log.txt:

> configure:79378: checking if dynamic loading works
> /home/schoelle/Code/Pike-v8.0.388/build/openbsd-6.0-amd64/smartlink gcc -c -g -fvisibility=hidden -O3 -pipe -ggdb -funswitch-loops -pthread -fPIC conftest.c -o conftest.o
> /home/schoelle/Code/Pike-v8.0.388/bin/smartlink gcc -Wl,-Bshareable -L/usr/local/lib -R/usr/local/lib -L/usr/X11R6/lib -R/usr/X11R6/lib -L/usr/lib/gcc-lib/amd64-unknown-openbsd6.0/4.2.1 -pthread conftest.o -o conftest.so
> configure:79430: /home/schoelle/Code/Pike-v8.0.388/build/openbsd-6.0-amd64/smartlink gcc -o conftest -g  -fvisibility=hidden -O3 -pipe -ggdb -funswitch-loops -pthread -Wl,-E  -I/usr/local/include -I/usr/X11R6/include -I/home/schoelle/Code/Pike-v8.0.388/src -I/home/schoelle/Code/Pike-v8.0.388/build/openbsd-6.0-amd64  -L/usr/local/lib -R/usr/local/lib -L/usr/X11R6/lib -R/usr/X11R6/lib -L/usr/lib/gcc-lib/amd64-unknown-openbsd6.0/4.2.1 -pthread conftest.c -lm  >&5
> In file included from conftest.c:258:
> /home/schoelle/Code/Pike-v8.0.388/src/dynamic_load.c: In function 'main':
> /home/schoelle/Code/Pike-v8.0.388/src/dynamic_load.c:719: warning: incompatible implicit declaration of built-in function 'exit'
> /home/schoelle/Code/Pike-v8.0.388/src/dynamic_load.c:725: warning: incompatible implicit declaration of built-in function 'exit'
> /home/schoelle/Code/Pike-v8.0.388/src/dynamic_load.c:732: warning: incompatible implicit declaration of built-in function 'exit'
> /home/schoelle/Code/Pike-v8.0.388/src/dynamic_load.c:737: warning: incompatible implicit declaration of built-in function 'exit'
> conftest.c: In function 'testfunc2':
> conftest.c:262: warning: incompatible implicit declaration of built-in function 'exit'
> configure:79430: $? = 0
> configure:79430: ./conftest
> conftest:./myconftest.so: undefined symbol 'main'
> Failed to link myconftest.so: Cannot load specified object
> configure:79430: $? = 1
> configure: program exited with status 1

The actual problem is the "./myconftest.so: undefined symbol 'main'",
which indicates that CCSHARED and/or LINKFORSHARED don't have the
correct contents. I suspect that the problem is with CCSHARED, as 
AFAIK myconftest.so shouldn't reference main at all.

This looks suspiciously like something I've already fixed in Pike 8.1:

|   if test "$GCC:$ldshared_is_cc" = "yes:yes" ; then
|     # On some architectures gcc attempts to link the shared object with
|     # the standard startup files (crt0.o et al), which may fail due to
|     # relocation errors. The flag -nostartfiles exists in gcc since at
|     # least version 3.3.2 from 2003, so this should be safe.
|     LDSHARED="$LDSHARED -nostartfiles"
|   fi

BTW: I believe that it's probably better to first attempt to get Pike 8.1
      running, and then backport the fixes to Pike 8.0, than the opposite.

      You can always get a fresh Pike 8.1 dist from Pikefarm:
      http://pike.lysator.liu.se/generated/pikefarm/packages/devel/latest

 	/grubba

-- 
Henrik Grubbström					[email protected]
Roxen Internet Software AB
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.