Thread overview
How to use dub with a manual ldc installation?
Nov 04, 2016
ZombineDev
Nov 04, 2016
John Colvin
Nov 04, 2016
Johannes Pfau
Nov 04, 2016
ZombineDev
November 04, 2016
So I'm working on the checkedint pull request (really need to get that in...) and was trying to get some benchmarks going with ldc. The stock ldc on mint is outdated and it can't compile the code, so I needed to do a self-installation. I've put it in ~/bin/ldc2-1.1.0-beta3-linux-x86. Then:

$ PATH=~/bin/ldc2-1.1.0-beta3-linux-x86/bin:$PATH
$ dub test --compiler=ldc2

I get:

Performing "unittest" build using ldc2 for x86.
checkedint_andralex 0.0.8: building configuration "__test__library__"...
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lrt
/usr/bin/ld: cannot find -ldl
/usr/bin/ld: cannot find -lpthread
/usr/bin/ld: cannot find -lm
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find -lc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
/usr/bin/ld: cannot find -lgcc_s
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1
ldc2 failed with exit code 1.

What happens here? I've added "-L-L/lib" and "-L-L/usr/lib" to ldc's configuration file, no avail.


Thanks,

Andrei
November 04, 2016
On 11/04/2016 01:12 PM, Andrei Alexandrescu wrote:
> So I'm working on the checkedint pull request (really need to get that
> in...) and was trying to get some benchmarks going with ldc. The stock
> ldc on mint is outdated and it can't compile the code, so I needed to do
> a self-installation. I've put it in ~/bin/ldc2-1.1.0-beta3-linux-x86. Then:
>
> $ PATH=~/bin/ldc2-1.1.0-beta3-linux-x86/bin:$PATH

Found the problem, sorry for the distraction. I'd downloaded the 32-bit version not the 64-bit one. I got it working with the right download.

BTW the benchmark results have been pretty good:

======================================
Running trialPrimes() benchmark...
                                     int: 37 ms, 789 μs, and 8 hnsecs
                     Checked!(int, void): 25 ms and 398 μs
                     Checked!(int, Warn): 64 ms, 653 μs, and 9 hnsecs
                                    uint: 42 ms, 361 μs, and 1 hnsec
                    Checked!(uint, void): 42 ms, 49 μs, and 5 hnsecs
                    Checked!(uint, Warn): 72 ms, 322 μs, and 7 hnsecs
                                    long: 67 ms and 893 μs
                    Checked!(long, void): 54 ms, 512 μs, and 3 hnsecs
                    Checked!(long, Warn): 91 ms and 932 μs
                                   ulong: 69 ms and 567 μs
                   Checked!(ulong, void): 69 ms, 136 μs, and 4 hnsecs
                   Checked!(ulong, Warn): 95 ms, 196 μs, and 7 hnsecs
DONE

Running collatzSort() benchmark...
                                     int: 43 ms, 967 μs, and 9 hnsecs
                     Checked!(int, void): 44 ms, 104 μs, and 8 hnsecs
                     Checked!(int, Warn): 81 ms, 833 μs, and 1 hnsec
                                    uint: 43 ms, 398 μs, and 3 hnsecs
                    Checked!(uint, void): 43 ms, 560 μs, and 6 hnsecs
                    Checked!(uint, Warn): 82 ms, 727 μs, and 7 hnsecs
                                    long: 43 ms, 208 μs, and 4 hnsecs
                    Checked!(long, void): 43 ms, 734 μs, and 5 hnsecs
                    Checked!(long, Warn): 83 ms, 868 μs, and 5 hnsecs
                                   ulong: 43 ms, 459 μs, and 4 hnsecs
                   Checked!(ulong, void): 43 ms, 544 μs, and 5 hnsecs
                   Checked!(ulong, Warn): 84 ms, 567 μs, and 7 hnsecs
DONE
======================================

The Checked!(int, void) type is a checkedint that just "goes through" the framework (it's a wrapper struct that doesn't insert any checks) and to ldc's credit it gets optimized to pretty much a built-in int.

The Checked!(int, Warn) type inserts all checks necessary to print a warning to stderr in case anything wrong happens. We're looking at a 2x speed reduction, which is up to par with Thomas' library (https://code.dlang.org/packages/checkedint). I've tried to run the corresponding test for that and ran into a snag. It does work with dmd but not with my locally-installed ldc. Any idea on what could be happening? Here's the trace:

$dub run checkedint:tests --build=release --verbose --compiler=$HOME/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2

Using dub registry url 'http://code.dlang.org/'
Refreshing local packages (refresh existing: true)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/andrei/.dub/packages/local-packages.json
No package found in current working directory.
Building package checkedint:tests in /home/andrei/.dub/packages/checkedint-0.5.3/tests/
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/andrei/.dub/packages/local-packages.json
Found dependency checkedint 0.5.3
Checking for missing dependencies.
Refreshing local packages (refresh existing: false)...
Looking for local package map at /var/lib/dub/packages/local-packages.json
Looking for local package map at /home/andrei/.dub/packages/local-packages.json
Found dependency checkedint 0.5.3
Checking for upgrades.
Using cached upgrade results...
Generating using build
Generate target checkedint:tests (executable /home/andrei/.dub/packages/checkedint-0.5.3/tests checkedint_tests)
Generate target checkedint (staticLibrary /home/andrei/.dub/packages/checkedint-0.5.3 checkedint)
Performing "release" build using /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 for x86_64.
Target '/home/andrei/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a' doesn't exist, need rebuild.
checkedint 0.5.3: building configuration "library"...
/home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 -lib -of.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a -release -enable-inlining -O -ignore -w -oq -od=.dub/obj -d-version=Have_checkedint -I.dub/packages/checkedint-0.5.3/source/ .dub/packages/checkedint-0.5.3/source/checkedint/asserts.d .dub/packages/checkedint-0.5.3/source/checkedint/flags.d .dub/packages/checkedint-0.5.3/source/checkedint/noex.d .dub/packages/checkedint-0.5.3/source/checkedint/package.d .dub/packages/checkedint-0.5.3/source/checkedint/throws.d .dub/packages/checkedint-0.5.3/source/checkedint/traits.d .dub/packages/checkedint-0.5.3/source/future/bitop.d .dub/packages/checkedint-0.5.3/source/future/math.d .dub/packages/checkedint-0.5.3/source/future/traits0.d
Error: failed to create path to file: .dub/obj/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a
No such file or directory
FAIL .dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/ checkedint staticLibrary
/home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 failed with exit code 1.


Andrei

November 04, 2016
Am Fri, 4 Nov 2016 13:12:42 -0400
schrieb Andrei Alexandrescu <SeeWebsiteForEmail@erdani.org>:

> So I'm working on the checkedint pull request (really need to get that in...) and was trying to get some benchmarks going with ldc. The stock ldc on mint is outdated and it can't compile the code, so I needed to do a self-installation. I've put it in ~/bin/ldc2-1.1.0-beta3-linux-x86. Then:
> 
> $ PATH=~/bin/ldc2-1.1.0-beta3-linux-x86/bin:$PATH
> $ dub test --compiler=ldc2
> 
> I get:
> 
> Performing "unittest" build using ldc2 for x86.
> checkedint_andralex 0.0.8: building configuration
> "__test__library__"... /usr/bin/ld: cannot find crt1.o: No such file
> or directory /usr/bin/ld: cannot find crti.o: No such file or
> directory /usr/bin/ld: cannot find -lrt
> /usr/bin/ld: cannot find -ldl
> /usr/bin/ld: cannot find -lpthread
> /usr/bin/ld: cannot find -lm
> /usr/bin/ld: skipping incompatible
> /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
> /usr/bin/ld: cannot find -lgcc
> /usr/bin/ld: skipping incompatible
> /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
> /usr/bin/ld: cannot find -lgcc_s
> /usr/bin/ld: cannot find -lc
> /usr/bin/ld: skipping incompatible
> /usr/lib/gcc/x86_64-linux-gnu/5/libgcc.a when searching for -lgcc
> /usr/bin/ld: cannot find -lgcc
> /usr/bin/ld: skipping incompatible
> /usr/lib/gcc/x86_64-linux-gnu/5/libgcc_s.so when searching for -lgcc_s
> /usr/bin/ld: cannot find -lgcc_s
> /usr/bin/ld: cannot find crtn.o: No such file or directory
> collect2: error: ld returned 1 exit status
> Error: /usr/bin/gcc failed with status: 1
> ldc2 failed with exit code 1.
> 
> What happens here? I've added "-L-L/lib" and "-L-L/usr/lib" to ldc's configuration file, no avail.
> 
> 
> Thanks,
> 
> Andrei

Looks like you are on a 64 bit system (x86_64) and using a 32 bit ldc. If this is intended it will probably work fine but you'll have to install the 32bit libc and gcc libraries.
November 04, 2016
On Friday, 4 November 2016 at 17:40:05 UTC, Andrei Alexandrescu wrote:
> On 11/04/2016 01:12 PM, Andrei Alexandrescu wrote:
>> So I'm working on the checkedint pull request (really need to get that
>> in...) and was trying to get some benchmarks going with ldc. The stock
>> ldc on mint is outdated and it can't compile the code, so I needed to do
>> a self-installation. I've put it in ~/bin/ldc2-1.1.0-beta3-linux-x86. Then:
>>
>> $ PATH=~/bin/ldc2-1.1.0-beta3-linux-x86/bin:$PATH
>
> Found the problem, sorry for the distraction. I'd downloaded the 32-bit version not the 64-bit one. I got it working with the right download.
>
> BTW the benchmark results have been pretty good:
>
> ======================================
> Running trialPrimes() benchmark...
>                                      int: 37 ms, 789 μs, and 8 hnsecs
>                      Checked!(int, void): 25 ms and 398 μs
>                      Checked!(int, Warn): 64 ms, 653 μs, and 9 hnsecs
>                                     uint: 42 ms, 361 μs, and 1 hnsec
>                     Checked!(uint, void): 42 ms, 49 μs, and 5 hnsecs
>                     Checked!(uint, Warn): 72 ms, 322 μs, and 7 hnsecs
>                                     long: 67 ms and 893 μs
>                     Checked!(long, void): 54 ms, 512 μs, and 3 hnsecs
>                     Checked!(long, Warn): 91 ms and 932 μs
>                                    ulong: 69 ms and 567 μs
>                    Checked!(ulong, void): 69 ms, 136 μs, and 4 hnsecs
>                    Checked!(ulong, Warn): 95 ms, 196 μs, and 7 hnsecs
> DONE
>
> Running collatzSort() benchmark...
>                                      int: 43 ms, 967 μs, and 9 hnsecs
>                      Checked!(int, void): 44 ms, 104 μs, and 8 hnsecs
>                      Checked!(int, Warn): 81 ms, 833 μs, and 1 hnsec
>                                     uint: 43 ms, 398 μs, and 3 hnsecs
>                     Checked!(uint, void): 43 ms, 560 μs, and 6 hnsecs
>                     Checked!(uint, Warn): 82 ms, 727 μs, and 7 hnsecs
>                                     long: 43 ms, 208 μs, and 4 hnsecs
>                     Checked!(long, void): 43 ms, 734 μs, and 5 hnsecs
>                     Checked!(long, Warn): 83 ms, 868 μs, and 5 hnsecs
>                                    ulong: 43 ms, 459 μs, and 4 hnsecs
>                    Checked!(ulong, void): 43 ms, 544 μs, and 5 hnsecs
>                    Checked!(ulong, Warn): 84 ms, 567 μs, and 7 hnsecs
> DONE
> ======================================
>
> The Checked!(int, void) type is a checkedint that just "goes through" the framework (it's a wrapper struct that doesn't insert any checks) and to ldc's credit it gets optimized to pretty much a built-in int.
>
> The Checked!(int, Warn) type inserts all checks necessary to print a warning to stderr in case anything wrong happens. We're looking at a 2x speed reduction, which is up to par with Thomas' library (https://code.dlang.org/packages/checkedint). I've tried to run the corresponding test for that and ran into a snag. It does work with dmd but not with my locally-installed ldc. Any idea on what could be happening? Here's the trace:
>
> $dub run checkedint:tests --build=release --verbose --compiler=$HOME/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2
>
> Using dub registry url 'http://code.dlang.org/'
> Refreshing local packages (refresh existing: true)...
> Looking for local package map at /var/lib/dub/packages/local-packages.json
> Looking for local package map at /home/andrei/.dub/packages/local-packages.json
> No package found in current working directory.
> Building package checkedint:tests in /home/andrei/.dub/packages/checkedint-0.5.3/tests/
> Refreshing local packages (refresh existing: false)...
> Looking for local package map at /var/lib/dub/packages/local-packages.json
> Looking for local package map at /home/andrei/.dub/packages/local-packages.json
> Found dependency checkedint 0.5.3
> Checking for missing dependencies.
> Refreshing local packages (refresh existing: false)...
> Looking for local package map at /var/lib/dub/packages/local-packages.json
> Looking for local package map at /home/andrei/.dub/packages/local-packages.json
> Found dependency checkedint 0.5.3
> Checking for upgrades.
> Using cached upgrade results...
> Generating using build
> Generate target checkedint:tests (executable /home/andrei/.dub/packages/checkedint-0.5.3/tests checkedint_tests)
> Generate target checkedint (staticLibrary /home/andrei/.dub/packages/checkedint-0.5.3 checkedint)
> Performing "release" build using /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 for x86_64.
> Target '/home/andrei/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a' doesn't exist, need rebuild.
> checkedint 0.5.3: building configuration "library"...
> /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 -lib -of.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a -release -enable-inlining -O -ignore -w -oq -od=.dub/obj -d-version=Have_checkedint -I.dub/packages/checkedint-0.5.3/source/ .dub/packages/checkedint-0.5.3/source/checkedint/asserts.d .dub/packages/checkedint-0.5.3/source/checkedint/flags.d .dub/packages/checkedint-0.5.3/source/checkedint/noex.d .dub/packages/checkedint-0.5.3/source/checkedint/package.d .dub/packages/checkedint-0.5.3/source/checkedint/throws.d .dub/packages/checkedint-0.5.3/source/checkedint/traits.d .dub/packages/checkedint-0.5.3/source/future/bitop.d .dub/packages/checkedint-0.5.3/source/future/math.d .dub/packages/checkedint-0.5.3/source/future/traits0.d
> Error: failed to create path to file: .dub/obj/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a
> No such file or directory
> FAIL .dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/ checkedint staticLibrary
> /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 failed with exit code 1.
>
>
> Andrei

Nice progress!

About the compilation problems that you're observing, it's most likely due to LDC issue https://github.com/ldc-developers/ldc/issues/1819, which has been fixed since LDC 1.1.0-beta3, though no new version of LDC have been released since the bug was fixed. You can either build LDC master from source, or workaround the problem by presenting LDC as DMD via ldmd2, that is:
dub run checkedint:tests --build=release --verbose --compiler=$HOME/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldmd2
November 04, 2016
On Friday, 4 November 2016 at 17:12:42 UTC, Andrei Alexandrescu wrote:
> [...]
> $ PATH=~/bin/ldc2-1.1.0-beta3-linux-x86/bin:$PATH
> $ dub test --compiler=ldc2
>
> [...]

BTW, you should try out the install script (from http://dlang.org/download):

curl -fsS https://dlang.org/install.sh | bash -s ldc-beta
source ~/dlang/ldc-1.1.0-beta3/activate

After the first time it's installed it's just

# To get the latest nightly (which as of today is 2016-11-04):
~/dlang/install.sh install dmd-nightly
source ~/dlang/dmd-master-2016-11-04/activate
dmd --version
DMD64 D Compiler v2.073.0-master-7637a2a

# To get a specific dmd version:
~/dlang/install.sh install dmd-2.071.0
source ~/dlang/dmd-2.071.0/activate
dmd --version
DMD64 D Compiler v2.071.0

# Etc... see install.sh --help for more info.

The script allows easy management of several D compiler installations and DUB.
November 04, 2016
On Friday, 4 November 2016 at 17:40:05 UTC, Andrei Alexandrescu wrote:
> Error: failed to create path to file: .dub/obj/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a
> No such file or directory
> FAIL .dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/ checkedint staticLibrary
> /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 failed with exit code 1.
>
>
> Andrei

Bug, fixed in master(s). Use --compiler=ldmd2 instead.
November 04, 2016
On 11/04/2016 07:01 PM, John Colvin wrote:
> On Friday, 4 November 2016 at 17:40:05 UTC, Andrei Alexandrescu wrote:
>> Error: failed to create path to file:
>> .dub/obj/.dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/libcheckedint.a
>>
>> No such file or directory
>> FAIL
>> .dub/packages/checkedint-0.5.3/.dub/build/library-release-linux.posix-x86_64-ldc_0-34AC553328DC970F29AC41DDB38D09AB/
>> checkedint staticLibrary
>> /home/andrei/bin/ldc2-1.1.0-beta3-linux-x86_64/bin/ldc2 failed with
>> exit code 1.
>>
>>
>> Andrei
>
> Bug, fixed in master(s). Use --compiler=ldmd2 instead.

Thanks, that worked. -- Andrei