www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - How to set the linker ldmd2 LTS uses.

reply Georgi D <georgid outlook.com> writes:
Hi,

I am trying to build LDC 1.1.1 using LDC LTS for bootstrap in a 
crosscompile environment where the system /usr/bin/gcc cannot be 
used. During the CMake generation I get:

```
Error: failed to locate gcc
CMake Error at cmake/Modules/ExtractDMDSystemLinker.cmake:40 
(message):
   Failed to compile empty program using D compiler
   '<toolchain>/bin/ldmd2'
Call Stack (most recent call first):
   CMakeLists.txt:559 (include)
```

When I run ldmd2 -v test.d manually I see it is using:

/usr/bin/gcc test.o -o test

for linking.

How can I specify the gcc location on the command line or in the 
environment?

Thanks
Mar 03 2017
parent reply David Nadlinger <code klickverbot.at> writes:
On Friday, 3 March 2017 at 21:35:13 UTC, Georgi D wrote:
 How can I specify the gcc location on the command line or in 
 the environment?
You should be able to use the CC environment variable. There is a hidden `gcc` switch as well, but I don't think we ever officially documented it. — David
Mar 03 2017
next sibling parent Georgi D <georgid outlook.com> writes:
On Friday, 3 March 2017 at 21:39:55 UTC, David Nadlinger wrote:
 On Friday, 3 March 2017 at 21:35:13 UTC, Georgi D wrote:
 How can I specify the gcc location on the command line or in 
 the environment?
You should be able to use the CC environment variable. There is a hidden `gcc` switch as well, but I don't think we ever officially documented it. — David
This worked. Thanks a lot.
Mar 03 2017
prev sibling parent reply Georgi D <georgid outlook.com> writes:
On Friday, 3 March 2017 at 21:39:55 UTC, David Nadlinger wrote:
 On Friday, 3 March 2017 at 21:35:13 UTC, Georgi D wrote:
 How can I specify the gcc location on the command line or in 
 the environment?
You should be able to use the CC environment variable. There is a hidden `gcc` switch as well, but I don't think we ever officially documented it. — David
One more question: Is it possible to have paths relative to the compiler executable in ldc.conf? This is important to me because in my environment the compiler is build in a build farm and then downloaded as part of the build process to the local machine and used. So the ldc.conf generated during compilation would contain paths to the build farm machine which are not usable locally. It would be great if ldc.conf could look like this: ``` // This configuration file uses libconfig. // See http://www.hyperrealm.com/libconfig/ for syntax details. // The default group is required default: { // 'switches' holds array of string that are appends to the command line // arguments before they are parsed. switches = [ "-I${__LDC_BIN}/../include/d/ldc", "-I${__LDC_BIN}/../include/d", "-L-L${__LDC_BIN}/../lib", "-defaultlib=phobos2-ldc,druntime-ldc", "-debuglib=phobos2-ldc-debug,druntime-ldc-debug" ]; }; ``` I see that ldmd2 looks for ldc.conf relative to its binary location already. Thanks,
Mar 03 2017
parent reply David Nadlinger via digitalmars-d-ldc <digitalmars-d-ldc puremagic.com> writes:
On 3 Mar 2017, at 23:10, Georgi D via digitalmars-d-ldc wrote:
 Is it possible to have paths relative to the compiler executable in 
 ldc.conf?
%%ldcbinarypath%% is what you are looking for. — David
Mar 03 2017
parent Georgi D <georgid outlook.com> writes:
On Friday, 3 March 2017 at 22:24:05 UTC, David Nadlinger wrote:
 On 3 Mar 2017, at 23:10, Georgi D via digitalmars-d-ldc wrote:
 Is it possible to have paths relative to the compiler 
 executable in ldc.conf?
%%ldcbinarypath%% is what you are looking for. — David
Yes, it worked perfectly. I think it would be useful to have an option for the CMake build to emit ldc2.conf which uses this parameter (A position independent build). Thanks
Mar 04 2017