On Monday, 26 March 2018 at 22:13:02 UTC, Johan Engelen wrote:
On Monday, 26 March 2018 at 22:07:49 UTC, Nordlöw wrote:
When I try build my application using LDC and -flto=thin it fails in the final linking

You must also pass `-flto=thin` during linking (a special plugin is needed for LTO, and LDC will only pass the plugin to the linker when `-flto=` is specified). I couldn't see `-flto=thin` in your link command, so I suspect that will fix it.

- Johan

I added `lflags` to my dub configuration as

buildType "release-nobounds-lto" {
buildOptions "releaseMode" "optimize" "inline" "noBoundsCheck" # TODO -march=native -ffast-math dflags "-mcpu=native" "-O3" "-flto=thin" platform="posix-ldc"
         lflags "-flto=thin" platform="posix-ldc"
}

forwarded as `-L-flto=thin` but still errors as

Linking...
ldmd2 -of.dub/build/application-release-nobounds-lto-linux.posix-x86_64-ldc_2078-F2904BE3C4DA237C077E5C2B0B23442E/knetquery .dub/build/application-release-nobounds-lto-linux.posix-x86_64-ldc_2078-F2904BE3C4DA237C077E5C2B0B23442E/knetquery.o ../../.dub/packages/gmp-d-master/gmp-d/.dub/build/library-release-nobounds-lto-linux.posix-x86_64-ldc_2078-B287F67CE5FF6145BC229790CFB09607/libgmp-d.a phobos-next/.dub/build/library-release-nobounds-lto-linux.posix-x86_64-ldc_2078-F0F2FDB01B8401C04D657BCC145D46A5/libknet_phobos-next.a -L--no-as-needed -L-flto=thin -L-lzstd -L-lgmp -L-lc -L-lreadline -L-lz -L-lbz2 /usr/bin/ld: error: .dub/build/application-release-nobounds-lto-linux.posix-x86_64-ldc_2078-F2904BE3C4DA237C077E5C2B0B23442E/knetquery.o:1:3: invalid character /usr/bin/ld: error: .dub/build/application-release-nobounds-lto-linux.posix-x86_64-ldc_2078-F2904BE3C4DA237C077E5C2B0B23442E/knetquery.o:1:3: syntax error, unexpected $end /usr/bin/ld: error: .dub/build/application-release-nobounds-lto-linux.posix-x86_64-ldc_2078-F2904BE3C4DA237C077E5C2B0B23442E/knetquery.o: not an object or archive
/usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o:function 
_start: error: undefined reference to 'main'
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1
FAIL .dub/build/application-release-nobounds-lto-linux.posix-x86_64-ldc_2078-F2904BE3C4DA237C077E5C2B0B23442E/ knetquery executable
ldmd2 failed with exit code 1.

Reply via email to