Instruct gdc to look for standard library in another directory

Johann krani at otomy.com
Sat Jul 1 06:53:02 UTC 2023


I have both `ldc` and `gdc` install on my OpenSUSE tumbleweed 
machine.

Without `ldc-runtime-devel`, `gdc` is able to compile 
successfully.
```bash
binary    /usr/lib64/gcc/x86_64-suse-linux/13/d21
version   v2.103.0-rc.1

predefs   GNU D_Version2 LittleEndian GNU_DWARF2_Exceptions 
GNU_StackGrowsDown GNU_InlineAsm D_LP64 assert D_PreConditions 
D_PostConditions D_Invariants D_ModuleInfo D_Exceptions 
D_TypeInfo all X86_64 D_HardFloat Posix linux CRuntime_Glibc 
CppRuntime_Gcc
parse     app
importall app
import    
object	(/usr/lib64/gcc/x86_64-suse-linux/13/include/d/object.d)


... rest omitted
```

However, after installing `ldc-runtime-devel`, gdc fails to 
compile a "hello world" because it tries to use the phobos 
library provided by ldc.

gdc installs its library at 
`/usr/lib64/gcc/x86_64-suse-linux/13/include/d/`
ldc installs its library at `/usr/include/d`

`gdc -v source/app.d` shows,


```bash
gcc version 13.1.1 20230522 [revision 
dd36656ada05731c069ecd5b1878380294fb1f3e] (SUSE Linux)
COLLECT_GCC_OPTIONS='-v' '-o' 'a.out' '-shared-libgcc' 
'-mtune=generic' '-march=x86-64' '-dumpdir' 'a-'
  /usr/lib64/gcc/x86_64-suse-linux/13/d21 source/app.d -quiet 
-dumpdir a- -dumpbase app.d -dumpbase-ext .d -mtune=generic 
-march=x86-64 -version -v -o /tmp/ccFpibdu.s
GNU D (SUSE Linux) version 13.1.1 20230522 [revision 
dd36656ada05731c069ecd5b1878380294fb1f3e] (x86_64-suse-linux)
	compiled by GNU C version 13.1.1 20230522 [revision 
dd36656ada05731c069ecd5b1878380294fb1f3e], GMP version 6.2.1, 
MPFR version 4.2.0-p9, MPC version 1.3.1, isl version isl-0.26-GMP

GGC heuristics: --param ggc-min-expand=100 --param 
ggc-min-heapsize=131072
binary    /usr/lib64/gcc/x86_64-suse-linux/13/d21
version   v2.103.0-rc.1

predefs   GNU D_Version2 LittleEndian GNU_DWARF2_Exceptions 
GNU_StackGrowsDown GNU_InlineAsm D_LP64 assert D_PreConditions 
D_PostConditions D_Invariants D_ModuleInfo D_Exceptions 
D_TypeInfo all X86_64 D_HardFloat Posix linux CRuntime_Glibc 
CppRuntime_Gcc
parse     app
importall app
import    object	(/usr/include/d/object.d)
import    core.attribute	(/usr/include/d/core/attribute.d)
import    
gcc.attributes	(/usr/lib64/gcc/x86_64-suse-linux/13/include/d/gcc/attributes.d)
import    core.internal.hash	(/usr/include/d/core/internal/hash.d)
import    
core.internal.traits	(/usr/include/d/core/internal/traits.d)
import    
core.internal.entrypoint	(/usr/include/d/core/internal/entrypoint.d)
import    
core.internal.array.appending	(/usr/include/d/core/internal/array/appending.d)
import    
core.internal.array.comparison	(/usr/include/d/core/internal/array/comparison.d)
import    
core.internal.array.equality	(/usr/include/d/core/internal/array/equality.d)
import    
core.internal.array.casting	(/usr/include/d/core/internal/array/casting.d)
import    
core.internal.array.concatenation	(/usr/include/d/core/internal/array/concatenation.d)
import    
core.internal.array.construction	(/usr/include/d/core/internal/array/construction.d)
import    
core.internal.array.arrayassign	(/usr/include/d/core/internal/array/arrayassign.d)
import    
core.internal.array.capacity	(/usr/include/d/core/internal/array/capacity.d)
import    
core.internal.dassert	(/usr/include/d/core/internal/dassert.d)
import    core.atomic	(/usr/include/d/core/atomic.d)
import    
core.internal.attributes	(/usr/include/d/core/internal/attributes.d)
import    
core.internal.atomic	(/usr/include/d/core/internal/atomic.d)
import    
gcc.builtins	(/usr/lib64/gcc/x86_64-suse-linux/13/include/d/gcc/builtins.d)
import    
gcc.config	(/usr/lib64/gcc/x86_64-suse-linux/13/include/d/gcc/config.d)
import    
core.internal.destruction	(/usr/include/d/core/internal/destruction.d)
import    
core.internal.moving	(/usr/include/d/core/internal/moving.d)
import    
core.internal.postblit	(/usr/include/d/core/internal/postblit.d)
import    
core.internal.switch_	(/usr/include/d/core/internal/switch_.d)
import    core.lifetime	(/usr/include/d/core/lifetime.d)
import    core.builtins	(/usr/include/d/core/builtins.d)
import    std.stdio	(/usr/include/d/std/stdio.d)
import    core.stdc.stddef	(/usr/include/d/core/stdc/stddef.d)
import    
std.algorithm.mutation	(/usr/include/d/std/algorithm/mutation.d)
import    std.traits	(/usr/include/d/std/traits.d)
import    std.meta	(/usr/include/d/std/meta.d)
import    
std.range.primitives	(/usr/include/d/std/range/primitives.d)
import    std.typecons	(/usr/include/d/std/typecons.d)
import    std.format.spec	(/usr/include/d/std/format/spec.d)
import    std.format.write	(/usr/include/d/std/format/write.d)
import    
std.format.internal.write	(/usr/include/d/std/format/internal/write.d)
import    
std.internal.attributes	(/usr/include/d/std/internal/attributes.d)
import    std.range	(/usr/include/d/std/range/package.d)
import    std.array	(/usr/include/d/std/array.d)
import    std.functional	(/usr/include/d/std/functional.d)
import    std.conv	(/usr/include/d/std/conv.d)
import    std.ascii	(/usr/include/d/std/ascii.d)
import    
std.range.interfaces	(/usr/include/d/std/range/interfaces.d)
import    core.stdc.stdio	(/usr/include/d/core/stdc/stdio.d)
import    core.stdc.stdint	(/usr/include/d/core/stdc/stdint.d)
import    core.stdc.config	(/usr/include/d/core/stdc/config.d)
import    core.stdc.signal	(/usr/include/d/core/stdc/signal.d)
import    core.stdc.wchar_	(/usr/include/d/core/stdc/wchar_.d)
import    core.stdc.stdarg	(/usr/include/d/core/stdc/stdarg.d)
import    core.stdc.time	(/usr/include/d/core/stdc/time.d)
import    
core.sys.posix.stdc.time	(/usr/include/d/core/sys/posix/stdc/time.d)
import    
core.sys.posix.sys.types	(/usr/include/d/core/sys/posix/sys/types.d)
import    
core.sys.posix.config	(/usr/include/d/core/sys/posix/config.d)
import    
core.sys.posix.stdio	(/usr/include/d/core/sys/posix/stdio.d)
semantic  app
import    std.exception	(/usr/include/d/std/exception.d)
import    core.stdc.errno	(/usr/include/d/core/stdc/errno.d)
entry     main	source/app.d
semantic2 app
semantic3 app
import    std.utf	(/usr/include/d/std/utf.d)
import    core.exception	(/usr/include/d/core/exception.d)
import    
core.internal.string	(/usr/include/d/core/internal/string.d)
import    
std.algorithm.comparison	(/usr/include/d/std/algorithm/comparison.d)
import    core.stdc.string	(/usr/include/d/core/stdc/string.d)
/usr/include/d/std/stdio.d:4322:18: error: none of the overloads 
of template ‘std.stdio.File.LockingTextWriter.put’ are callable 
using argument types ‘!()(string)’
  4322 |             w.put(args[0]);
       |                  ^
/usr/include/d/std/stdio.d:3248:14: note: Candidates are: 
‘put(A)(scope A writeme)’
      with `A = string`
   whose parameters have the following constraints:
   `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
`      > isSomeChar!(ElementType!A)
         or:
       > is(ElementType!A : const(ubyte))
   - isInputRange!A
   - !isInfinite!A
`  `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
  3248 |         void put(A)(scope A writeme)
       |              ^
/usr/include/d/std/stdio.d:3278:14: note:                 
‘put(C)(scope C c)’
      with `C = string`
   whose parameters have the following constraints:
   `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
`  > isSomeChar!C
     or:
   > is(C : const(ubyte))
`  `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
  3278 |         void put(C)(scope C c) @safe if (isSomeChar!C || 
is(C : const(ubyte)))
       |              ^
not satisfied constraints are marked with ‘>’
/usr/include/d/std/stdio.d:3299:56: error: none of the overloads 
of template ‘std.utf.decodeFront’ are callable using argument 
types ‘!()(char[])’
  3299 |                         immutable dchar d = 
decodeFront(str);
       |                                                        ^
/usr/include/d/std/utf.d:1245:7: note: Candidates are: 
‘decodeFront(Flag useReplacementDchar = No.useReplacementDchar, 
S)(ref S str, out size_t numCodeUnits)’
  1245 | dchar decodeFront(UseReplacementDchar useReplacementDchar 
= No.useReplacementDchar, S)(
       |       ^
/usr/include/d/std/utf.d:1285:7: note:                 
‘decodeFront(Flag useReplacementDchar = No.useReplacementDchar, 
S)(ref scope S str, out size_t numCodeUnits)’
  1285 | dchar decodeFront(UseReplacementDchar useReplacementDchar 
= No.useReplacementDchar, S)(
       |       ^
/usr/include/d/std/utf.d:1314:7: note:                 
‘decodeFront(Flag useReplacementDchar = No.useReplacementDchar, 
S)(ref S str)’
      with `useReplacementDchar = Flag.no,
        S = char[]`
   whose parameters have the following constraints:
   `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
`  > isInputRange!S
   - isSomeChar!(ElementType!S)
`  `~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
  1314 | dchar decodeFront(UseReplacementDchar useReplacementDchar 
= No.useReplacementDchar, S)(ref S str)
       |       ^
not satisfied constraints are marked with ‘>’
/usr/include/d/std/utf.d:2311:15: error: ‘object._d_newclassT’ 
not found. The current runtime does not support new class, or the 
runtime is corrupt.
  2311 |         throw new UTFException(msg).setSequence(c);
       |               ^
/usr/include/d/std/utf.d:2514:13: error: template instance 
‘std.utf._utfException!Flag.no’ error instantiating
  2514 |         c = _utfException!useReplacementDchar("Encoding 
an invalid code point in UTF-32", c);
       |             ^
/usr/include/d/std/stdio.d:3301:48: note: instantiated from here: 
‘encode!Flag.no’
  3301 |                         immutable size = encode(wbuf, d);
       |                                                ^
/usr/include/d/std/stdio.d:4324:14: note: instantiated from here: 
‘put!char’
  4324 |         w.put('\n');
       |              ^
source/app.d:5:16: note: instantiated from here: ‘writeln!string’
     5 |         writeln("Edit source/app.d to start your 
project.");
       |                ^
/usr/include/d/core/internal/entrypoint.d:41:17: error: 
unrecognized ‘pragma(LDC_profile_instr)’
    41 |                 pragma(LDC_profile_instr, false);
       |                 ^
source/app.d:3:6: note: parent scope from here: ‘mixin 
_d_cmain!()’
     3 | void main()
       |      ^
```


How may I fix it? I tried to use "-I" and "-B" option, but to no 
avail.


More information about the D.gnu mailing list