CyberShadow / Digger

A tool to build D and bisect old D versions
Other
57 stars 9 forks source link

Digger LDC compilation fails with undefined reference 'deflate'. #53

Closed aermicioi closed 5 years ago

aermicioi commented 7 years ago

fetching using dub, and compiliing Digger v3.0.0-alpha-1 using ldc2 will fail with: /usr/bin/ld: .dub/obj/digger.o: undefined reference to symbol 'deflate'

LDC Version: 1.1.0 DUB Version: 1.2.0

aermicioi commented 7 years ago

Adding zlib as library dependency to dub, seems to fix it.

CyberShadow commented 7 years ago

Hmm, I can't reproduce this:

~/work/Digger » dub build --compiler=ldc
Fetching ae 0.0.1905 (getting selected version)...
Performing "debug" build using ldc for x86_64.
digger 3.0.0-alpha-1+commit.23.gabaf8dd: building configuration "application"...
dub build --compiler=ldc  18.64s user 0.87s system 87% cpu 22.168 total

~/work/Digger » dub build :web --compiler=ldc 
Building package digger:web in /home/vladimir/work/Digger/
Performing "debug" build using ldc for x86_64.
digger:web 3.0.0-alpha-1+commit.23.gabaf8dd: building configuration "application"...
dub build :web --compiler=ldc  15.63s user 0.82s system 99% cpu 16.478 total
CyberShadow commented 7 years ago

@aermicioi Ping

aermicioi commented 7 years ago

Here is full error log:

aermicioi@aermicioi-laptop:~/.dub/packages$ dub build digger --compiler=dmd
Building package digger in /home/aermicioi/.dub/packages/digger-3.0.0-alpha-5/digger/
Fetching ae 0.0.1959 (getting selected version)...
Performing "debug" build using dmd for x86_64.
digger 3.0.0-alpha-5: building configuration "application"...
Linking...
aermicioi@aermicioi-laptop:~/.dub/packages$ dub build digger --compiler=ldc2
Building package digger in /home/aermicioi/.dub/packages/digger-3.0.0-alpha-5/digger/
Performing "debug" build using ldc2 for x86_64.
digger 3.0.0-alpha-5: building configuration "application"...
/usr/bin/ld: .dub/obj/digger.o: undefined reference to symbol 'deflate'
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1
ldc2 failed with exit code 1.

Note that for dmd everything is fine, though not sure why for ldc is not. It seems that ldc, or dub is not adding zlib library as a link dependency to the digger application, ending in missing deflate function.

Adding "libs": ["zlib"] to dub.json of package seems to fix the problem (ldc is linking zlib library).

As of why it is not reproducible, I'm not sure. The zlib package is installed on system.

The system is: debian sid amd64 LDC version: LDC - the LLVM D compiler (1.1.1) DUB version: DUB version 1.3.0, built on Apr 10 2017

CyberShadow commented 7 years ago

error adding symbols: DSO missing from command line

This line points towards a dub or ldc linking issue.

Can you reproduce it by invoking the compiler directly? E.g. (with the submodule cloned):

ldmd2 -debug digger.d ae/utils/json.d ae/sys/d/cache.d ae/utils/meta/package.d ae/utils/main.d ae/sys/net/package.d ae/utils/array.d ae/utils/meta/binding_v1.d ae/sys/persistence/stringset.d ae/utils/meta/proxy.d ae/sys/cmd.d ae/sys/file.d ae/net/http/client.d ae/utils/time/parse.d repo.d ae/utils/gzip.d ae/sys/install/git.d ae/utils/textout.d ae/sys/persistence/json.d ae/sys/paths.d ae/sys/memory.d ae/sys/data.d ae/sys/install/kindlegen.d ae/utils/meta/x.d ae/sys/dataset.d ae/utils/regex.d ae/sys/net/ae.d ae/net/ietf/headerparse.d ae/utils/funopt.d ae/net/ietf/url.d ae/utils/time/common.d ae/utils/meta/reference.d ae/sys/d/repo.d ae/sys/timing.d ae/utils/time/package.d ae/utils/time/parsedur.d bisect.d config.d ae/utils/text/package.d ae/sys/persistence/core.d ae/sys/archive.d ae/net/ssl/package.d ae/sys/install/common.d ae/utils/sini.d ae/utils/time/format.d ae/utils/digest.d ae/sys/persistence/package.d ae/utils/meta/caps.d ae/sys/install/sevenzip.d ae/sys/git.d common.d ae/sys/d/manager.d ae/utils/path.d ae/sys/persistence/memoize.d ae/net/ietf/headers.d ae/utils/text/ascii.d ae/utils/appender.d ae/sys/install/dmd.d ae/utils/zlib.d ae/sys/signals.d custom.d ae/utils/aa.d ae/net/asockets.d ae/utils/time/fpdur.d ae/utils/exception.d ae/utils/math.d install.d ae/utils/digest_murmurhash3.d ae/net/http/common.d ae/utils/meta/binding.d

BTW maybe we should meet up some day, not many D users around here :)

aermicioi commented 7 years ago

yeah it gives same error:

/usr/bin/ld: digger.o: undefined reference to symbol 'deflate'

it seems it's from ldc and not digger.

BTW maybe we should meet up some day, not many D users around here :)

sure, why not?

CyberShadow commented 7 years ago

yeah it gives same error:

In which case I suggest reporting this problem to the LDC bug tracker: https://github.com/ldc-developers/ldc/issues

CyberShadow commented 6 years ago

Is this still an issue? Has there been any follow-up on the LDC side?

dkgroot commented 6 years ago

It would help to add

libs_posix "zlib"

to the ae/dub.sdl. It should not have a negative impact when dmd is used as the compiler (which would resolve the dependency on zlib and include it anyway (just without any help from dub))..

CyberShadow commented 6 years ago

Good idea, let's do that if this is still an issue. Is it?

dkgroot commented 6 years ago

It is for me :-) This issue can depend on the linux version you are running (for example ubuntu/debian does have this issue). In this case adding libs_posix should not have a negative side effect.

CyberShadow commented 6 years ago

All right. Is it actually "zlib" though? The library file is called libz, and vibe.d uses libs "z".

CyberShadow commented 6 years ago

Looking more at Vibe's dub.sdl, I found this:

https://github.com/cybershadow/vibe.d/commit/2a7b73ca3600de727e3338d0266f1b9d11c26c8d

The commit message implies that this should have been fixed in LDC, but apparently it wasn't or it regressed?

@dkgroot I'll copy the libs directive from Vibe, but would you mind following up on this on the LDC issue tracker?

dkgroot commented 6 years ago

@CyberShadow Just added it to my local version, and it seems to work fine.

CyberShadow commented 5 years ago

Adding libs "zlib" for POSIX didn't break anything for me, so I went ahead with it. Hopefully it will still help.

JohanEngelen commented 1 year ago

On macOS 12.4, AArch64, building with LDC 1.27, I need to comment out libs "zlib" platform="posix" (linker does not find zlib), and then it builds fine.

CyberShadow commented 1 year ago

On macOS 12.4, AArch64, building with LDC 1.27, I need to comment out libs "zlib" platform="posix" (linker does not find zlib), and then it builds fine.

Do you know if it pulls zlib from somewhere else, then? Or, perhaps you just need to install the (development) zlib library?

JohanEngelen commented 1 year ago

I don't really know, but it looks like zlib source is part of phobos: https://github.com/ldc-developers/phobos/tree/321adbf4d9114139c623406d9517c7e833bc1114/etc/c/zlib

CyberShadow commented 1 year ago

So it looks like what libs "zlib" does is make Dub consult pkg-config for the configuration for zlib. As such, in case of any issues with linking zlib, the first step is to make sure that you have the pkg-config configuration for it. For example, pkg-config --libs zlib should print -lz.