dub
dub copied to clipboard
dub generate empty/invalid -J [was: grpc-dlang build failure with ldc2]
update:
@kinke find the cause of the problem:
"""
it looks like -J -lib is the problem. LDC accepts -Jmy/dir as well as -J my/dir, so an empty/invalid -J swallows the consecutive -lib arg.
"""
The dub.json that triggered this problem is in the comments https://github.com/dlang/dub/issues/2133#issuecomment-846466274
System information
Linux, amd64
ldc2 version 1.24.0 (DMD v2.094.1, LLVM 11.0.1)
DUB version 1.24.0-1, built on Jan 27 2021
Bug Description
grpc-dlang build failure with ldc2
dub build with dmd works fine
dub build --compiler=ldc2 fails with many undefined reference errors.
How to reproduce?
Follow instructions on:
https://github.com/huntlabs/grpc-dlang/blob/master/README.md
- Building the protocol buffer compiler for D
- Building the gRPC plugin for D
- Building the core library: but use
dub build --compiler=ldc2
Expected Behavior
ldc2 build should be successful.
Logs
more detailed log is here https://github.com/huntlabs/hunt/issues/89
the first few errors:
user@debian:~/grpc-dlang$ dub build --compiler=ldc2
Fetching hunt-http 0.7.3 (getting selected version)...
Fetching hunt-openssl 1.0.5 (getting selected version)...
Fetching hunt 1.7.7 (getting selected version)...
Fetching hunt-net 0.6.6 (getting selected version)...
Fetching protobuf 0.6.2 (getting selected version)...
Fetching hunt-extra 1.1.3 (getting selected version)...
Performing "debug" build using ldc2 for x86_64.
grpc 0.4.0-beta.1: building configuration "library"...
/usr/lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/Scrt1.o:function _start: error: undefined reference to 'main'
/home/user/grpc-dlang/source/grpc/GrpcStream.d:85: error: undefined reference to '_D4hunt2io11BufferUtilsQn8toStringFCQBiQBg10ByteBufferQmZAya'
/home/user/grpc-dlang/../.dub/packages/hunt-1.7.7/hunt/source/hunt/logging/Logger.d-mixin-584:584: error: undefined reference to '_D4hunt7logging6Logger8g_loggerCQBeQBcQxQz'
/home/user/grpc-dlang/../.dub/packages/hunt-1.7.7/hunt/source/hunt/logging/Logger.d-mixin-584:587: error: undefined reference to '_D4hunt7logging6LoggerQh8toFormatFAyaQdQfmEQBpQBnQBi8LogLevelZQBc'
/home/user/grpc-dlang/../.dub/packages/hunt-1.7.7/hunt/source/hunt/logging/Logger.d-mixin-584:587: error: undefined reference to '_D4hunt7logging6LoggerQh16writeFormatColorFEQBqQBoQBj8LogLevelAyaZv'
/home/user/grpc-dlang/../.dub/packages/hunt-1.7.7/hunt/source/hunt/logging/Logger.d-mixin-584:0: error: undefined reference to '_D4hunt7logging6Logger8g_loggerCQBeQBcQxQz'
/home/user/grpc-dlang/../.dub/packages/hunt-1.7.7/hunt/source/hunt/logging/Logger.d-mixin-584:589: error: undefined reference to '_D4hunt7logging6LoggerQh8toFormatFAyaQdQfmEQBpQBnQBi8LogLevelZQBc'
...
The build file is very simple, nothing suspicious:
https://github.com/huntlabs/grpc-dlang/blob/master/dub.json
See also: https://github.com/ldc-developers/ldc/issues/3723
I tried to use dub build -v --compiler=ldmd2 here to print out the exact command:
It is building a library: (I specifically added: "targetType": "library" to the dub.json)
~/project/contrib/grpc-dlang 16:22:36$ cat dub.json
{
"name": "grpc",
"targetType": "library",
"license": "Apache-2.0",
"copyright": "Copyright (C) 2018-2021 HuntLabs",
"homepage": "https://www.huntlabs.net",
"description": "gRPC implementation for D programming language",
"dependencies": {
"hunt-http": "~>0.7.0",
"protobuf": "~>0.6.2"
}
}
with this same dub.json file,
~/project/ldc2/bin/dub build -v --compiler=dmd // successful build
~/project/ldc2/bin/dub build -v --compiler=ldmd2 // same build error above
The error is here: """ ... Performing "debug" build using ldmd2 for x86_64. Target '/home/x/project/contrib/grpc-dlang/.dub/build/library-debug-linux.posix-x86_64-ldc_v1.26.0-C3E1A3C9CD32A6FC331A53471EAF68DB/libgrpc.a' doesn't exist, need rebuild. grpc 0.4.0-beta.1: building configuration "library"... ldmd2 -J -lib -of.dub/build/library-debug-linux.posix-x86_64-ldc_v1.26.0-C3E1A3C9CD32A6FC331A53471EAF68DB/libgrpc.a -debug -g -w -version=Have_grpc -version=Have_hunt_http -version=Have_protobuf -version=Have_hunt_net -version=Have_hunt_extra -version=Have_hunt -version=HAVE_EPOLL -Isource/ -I../../../.dub/packages/hunt-http-0.7.3/hunt-http/source/ -I../../../.dub/packages/hunt-net-0.6.6/hunt-net/source/ -I../../../.dub/packages/hunt-extra-1.1.3/hunt-extra/source/ -I../../../.dub/packages/hunt-1.7.7/hunt/source/ -I../../../.dub/packages/protobuf-0.6.2/protobuf/src/ -J../../../.dub/packages/hunt-extra-1.1.3/hunt-extra/resources source/grpc/EvBuffer.d source/grpc/GrpcClient.d source/grpc/GrpcCode.d source/grpc/GrpcException.d source/grpc/GrpcServer.d source/grpc/GrpcService.d source/grpc/GrpcStream.d source/grpc/Status.d source/grpc/StatusCode.d source/grpc/package.d source/grpc/stream/ClientReader.d source/grpc/stream/ClientReaderWriter.d source/grpc/stream/ClientWriter.d source/grpc/stream/ServerReader.d source/grpc/stream/ServerReaderWriter.d source/grpc/stream/ServerWriter.d -vcolumns /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:function _start: error: undefined reference to 'main' ... """
According to @kinke , https://github.com/ldc-developers/ldc/issues/3723
""" The error is emitted by the linker. The linker isn't invoked by LDC with -lib. So either dub isn't printing the actual failing command-line, or you've just missed it. """
I don't think I missed it, and I copied the lines before the command (it says: building configuration "library"), and 1 line after the command (it's the error: undefined reference to 'main')
I didn't see any linker command.
@kinke find the cause of the problem: """ it looks like -J -lib is the problem. LDC accepts -Jmy/dir as well as -J my/dir, so an empty/invalid -J swallows the consecutive -lib arg. """
The dub.json that triggered this problem is in the above comments https://github.com/dlang/dub/issues/2133#issuecomment-846466274
Thank you for following this issue.
reproduction case with https://github.com/huntlabs/grpc-dlang/blob/919cd6ae95fd0f0d380f5abe2603c9fac07374fc/dub.json works with current dub version, the -J -lib issue doesn't seem to appear anymore.
Gonna close this, feel free to reopen if you have another reproduction case.