Jump to page: 1 2
Thread overview
Re: strange -fPIC compilation error
Oct 30, 2016
Charles Hixson
Oct 31, 2016
Charles Hixson
Oct 31, 2016
Lodovico Giaretta
Oct 31, 2016
Charles Hixson
Oct 31, 2016
Daniel Kozak
Oct 31, 2016
Sebastien Alaiwan
Nov 01, 2016
TheGag96
Nov 01, 2016
Lodovico Giaretta
Oct 31, 2016
Charles Hixson
Oct 31, 2016
Charles Hixson
Oct 31, 2016
Daniel Kozak
Oct 31, 2016
Charles Hixson
Nov 01, 2016
Mike Parker
Nov 01, 2016
Nordlöw
Nov 01, 2016
Charles Hixson
Nov 01, 2016
bachmeier
Nov 01, 2016
Charles Hixson
Oct 31, 2016
Daniel Kozak
Oct 31, 2016
Charles Hixson
October 30, 2016
Just as a test I tried it with ldc, and, as expected, there wasn't any problem.


On 10/30/2016 11:02 AM, Charles Hixson via Digitalmars-d-learn wrote:
>  dmd --version
> DMD64 D Compiler v2.071.2
> Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
> on debian testing.
>
> dub is installed via apt-get.
>
> Should I revert to an earlier version?  Or what?
>
> The program:
>
>
> import    std.stdio;
>
> void    main()
> {    //int[]    t1;
>
>     //t1    ~=    1;
>     //t1    ~=    2;
>     //writeln ("t1 = ", t1);
> }
>
> fails with the 442 lines of error:
>
> /usr/bin/ld: test.o: relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(exception_224_3b4.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(exception_227_4a2.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(exception_229_5cc.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(dmain2_626_47b.o): relocation R_X86_64_32 against symbol `_D6object9Throwable7__ClassZ' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(dmain2_628_776.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(dwarfeh_62b_6b9.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> ...
>
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(aaA_51a_53e.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Nonrepresentable section on output
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
>
>

October 30, 2016
So now I removed the repository version of dmd and dub, downloaded DMD64 D Compiler v2.072.0-b2, used dkpg to install it, and appear to get the same errors.

(Well, actually I removed the commenting out of the code, but it compiles and runs properly with ldc2.)


On 10/30/2016 11:02 AM, Charles Hixson via Digitalmars-d-learn wrote:
>  dmd --version
> DMD64 D Compiler v2.071.2
> Copyright (c) 1999-2015 by Digital Mars written by Walter Bright
> on debian testing.
>
> dub is installed via apt-get.
>
> Should I revert to an earlier version?  Or what?
>
> The program:
>
>
> import    std.stdio;
>
> void    main()
> {    //int[]    t1;
>
>     //t1    ~=    1;
>     //t1    ~=    2;
>     //writeln ("t1 = ", t1);
> }
>
> fails with the 442 lines of error:
>
> /usr/bin/ld: test.o: relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(exception_224_3b4.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(exception_227_4a2.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(exception_229_5cc.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(dmain2_626_47b.o): relocation R_X86_64_32 against symbol `_D6object9Throwable7__ClassZ' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(dmain2_628_776.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(dwarfeh_62b_6b9.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> ...
>
> /usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(aaA_51a_53e.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
> /usr/bin/ld: final link failed: Nonrepresentable section on output
> collect2: error: ld returned 1 exit status
> --- errorlevel 1
>
>

October 31, 2016
On Monday, 31 October 2016 at 00:08:59 UTC, Charles Hixson wrote:
> So now I removed the repository version of dmd and dub, downloaded DMD64 D Compiler v2.072.0-b2, used dkpg to install it, and appear to get the same errors.
>
> (Well, actually I removed the commenting out of the code, but it compiles and runs properly with ldc2.)

I don't think it's a problem of DMD. This is due to your gcc installation being hardened, that is, configured to produce PIE by default. To produce PIE, the linker needs to be fed PIC, which DMD does not produce by default. The -fPIC flags makes DMD produce PIC out of your sources. The problem is, libphobos2.a (the static version of Phobos) is not compiled with -fPIC, so even if your code is PIC, gcc will complain. The workaround is to use -defaultlib=libphobos2.so to dynamically link with the shared version of Phobos. Being it a shared object, it does not give any problem with PIE.

Looking on internet, I didn't find any clue about Debian shipping an hardened gcc, but this is the only cause I can think of for the behaviour you are experiencing.
October 30, 2016

On 10/30/2016 05:14 PM, Lodovico Giaretta via Digitalmars-d-learn wrote:
> On Monday, 31 October 2016 at 00:08:59 UTC, Charles Hixson wrote:
>> So now I removed the repository version of dmd and dub, downloaded DMD64 D Compiler v2.072.0-b2, used dkpg to install it, and appear to get the same errors.
>>
>> (Well, actually I removed the commenting out of the code, but it compiles and runs properly with ldc2.)
>
> I don't think it's a problem of DMD. This is due to your gcc installation being hardened, that is, configured to produce PIE by default. To produce PIE, the linker needs to be fed PIC, which DMD does not produce by default. The -fPIC flags makes DMD produce PIC out of your sources. The problem is, libphobos2.a (the static version of Phobos) is not compiled with -fPIC, so even if your code is PIC, gcc will complain. The workaround is to use -defaultlib=libphobos2.so to dynamically link with the shared version of Phobos. Being it a shared object, it does not give any problem with PIE.
>
> Looking on internet, I didn't find any clue about Debian shipping an hardened gcc, but this is the only cause I can think of for the behaviour you are experiencing.
>
Well, that certainly changed the error messages.  With
dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d
I get:
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1124): Error: mismatched number of curly brackets
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1125): Error: mismatched number of curly brackets
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1126): Error: mismatched number of curly brackets
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1127): Error: mismatched number of curly brackets
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1128): Error: mismatched number of curly brackets
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1129): Error: mismatched number of curly brackets
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1133): Error: asm statements must end in ';'
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1136): Error: found 'private' instead of statement
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1146): Error: no identifier for declarator add
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: no identifier for declarator usDone
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: Declaration expected, not ':'
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1157): Error: Declaration expected, not '('
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not 'foreach'
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not '0'
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: no identifier for declarator __fhnd_info[fd]
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: Declaration expected, not '='
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1165): Error: Declaration expected, not 'return'
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
/usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration

October 31, 2016
Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a):

>
> Well, that certainly changed the error messages.  With
> dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d
> I get:
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1124): Error: mismatched number of curly brackets
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1125): Error: mismatched number of curly brackets
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1126): Error: mismatched number of curly brackets
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1127): Error: mismatched number of curly brackets
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1128): Error: mismatched number of curly brackets
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1129): Error: mismatched number of curly brackets
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1133): Error: asm statements must end in ';'
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1136): Error: found 'private' instead of statement
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1146): Error: no identifier for declarator add
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: no identifier for declarator usDone
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: Declaration expected, not ':'
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1157): Error: Declaration expected, not '('
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not 'foreach'
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not '0'
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: no identifier for declarator __fhnd_info[fd]
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: Declaration expected, not '='
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1165): Error: Declaration expected, not 'return'
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
>
This seems to be problem with your installation, you probably have diferen version of dmd compiler and phobos library. So you should uninstall all your dmd packages and make sure there is no /usr/include/dmd left in your system. And instal dmd only from one source (d-apt idealy).
October 31, 2016
Hello,
From GCC 6.2, -fpie is becoming the default setting at compile and at link time.
As dmd uses GCC to link, now the code needs to be compiled with a special option.
Which means you need, at the moment, to add the following options to your dmd.conf:
 -defaultlib=libphobos2.so -fPIC
(the change from GCC is related to security and address space randomization).
October 31, 2016
On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote:
> Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a):
>
>>
>> Well, that certainly changed the error messages.  With
>> dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d
>> I get:
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1124): Error: mismatched number of curly brackets
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1125): Error: mismatched number of curly brackets
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1126): Error: mismatched number of curly brackets
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1127): Error: mismatched number of curly brackets
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1128): Error: mismatched number of curly brackets
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1129): Error: mismatched number of curly brackets
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1133): Error: asm statements must end in ';'
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1136): Error: found 'private' instead of statement
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1146): Error: no identifier for declarator add
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: no identifier for declarator usDone
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: Declaration expected, not ':'
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1157): Error: Declaration expected, not '('
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not 'foreach'
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not '0'
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: no identifier for declarator __fhnd_info[fd]
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: Declaration expected, not '='
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1165): Error: Declaration expected, not 'return'
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
>> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
>>
> This seems to be problem with your installation, you probably have diferen version of dmd compiler and phobos library. So you should uninstall all your dmd packages and make sure there is no /usr/include/dmd left in your system. And instal dmd only from one source (d-apt idealy).
>
I've done that 2 or 3 times.  If that's the problem, then there are different versions stored in the repository.  Since I'm on debian testing I'd been assuming that there'd been some system change since I'd last used the compiler, and the debs weren't yet up to date. The only updates to my system prior to the compiler breaking HAD been via apt-get.  Since then I've used dpkg remove and install a couple of times to try other versions of dmd with no benefit.
Currently dmd-bin version 2.071.2-0
              libphobos            2.071.2-0
              libphobos            2.071.2-0
so they're LISTED as being the same version.  And dmd.conf was installed by the deb, and is (eliminating the comments):
[Environment32]
DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L--export-dynamic

[Environment64]
DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic

But somewhere during the process (which included the nightly system update) the error messages changed, and now:
dmd test.d
yields:
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
...
/usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
/usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration

October 31, 2016
On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote:
> On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote:
>> Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a):
>>
>>>
>>> Well, that certainly changed the error messages.  With
>>> dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d
>>> I get:
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1124): Error: mismatched number of curly brackets
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1125): Error: mismatched number of curly brackets
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1126): Error: mismatched number of curly brackets
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1127): Error: mismatched number of curly brackets
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1128): Error: mismatched number of curly brackets
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1129): Error: mismatched number of curly brackets
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1133): Error: asm statements must end in ';'
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1136): Error: found 'private' instead of statement
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1146): Error: no identifier for declarator add
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: no identifier for declarator usDone
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: Declaration expected, not ':'
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1157): Error: Declaration expected, not '('
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not 'foreach'
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not '0'
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: no identifier for declarator __fhnd_info[fd]
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: Declaration expected, not '='
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1165): Error: Declaration expected, not 'return'
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
>>> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
>>>
>> This seems to be problem with your installation, you probably have diferen version of dmd compiler and phobos library. So you should uninstall all your dmd packages and make sure there is no /usr/include/dmd left in your system. And instal dmd only from one source (d-apt idealy).
>>
> I've done that 2 or 3 times.  If that's the problem, then there are different versions stored in the repository.  Since I'm on debian testing I'd been assuming that there'd been some system change since I'd last used the compiler, and the debs weren't yet up to date. The only updates to my system prior to the compiler breaking HAD been via apt-get.  Since then I've used dpkg remove and install a couple of times to try other versions of dmd with no benefit.
> Currently dmd-bin version 2.071.2-0
>               libphobos            2.071.2-0
>               libphobos            2.071.2-0
> so they're LISTED as being the same version.  And dmd.conf was installed by the deb, and is (eliminating the comments):
> [Environment32]
> DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L--export-dynamic
>
> [Environment64]
> DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic
>
> But somewhere during the process (which included the nightly system update) the error messages changed, and now:
> dmd test.d
> yields:
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
> ...
> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
FWIW starting at /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121)::
        asm nothrow @nogc
        {
            mov EDX, num;
            lock;
            inc _iSemLockCtrs[EDX * 2];
so nothrow isn't being seen as appropriate at the beginning of an asm block.  After that I think it gets confused as 1123 doesn't HAVE a brace (i.e. curly bracket) in it.

October 31, 2016
Dne 31.10.2016 v 18:06 Charles Hixson via Digitalmars-d-learn napsal(a):
>
> On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote:
>> On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote:
>>> Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a):
>>>
>>>>
>>>> Well, that certainly changed the error messages.  With
>>>> dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d
>>>> I get:
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1124): Error: mismatched number of curly brackets
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1125): Error: mismatched number of curly brackets
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1126): Error: mismatched number of curly brackets
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1127): Error: mismatched number of curly brackets
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1128): Error: mismatched number of curly brackets
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1129): Error: mismatched number of curly brackets
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1133): Error: asm statements must end in ';'
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1136): Error: found 'private' instead of statement
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1146): Error: no identifier for declarator add
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: no identifier for declarator usDone
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: Declaration expected, not ':'
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1157): Error: Declaration expected, not '('
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not 'foreach'
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not '0'
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: no identifier for declarator __fhnd_info[fd]
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: Declaration expected, not '='
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1165): Error: Declaration expected, not 'return'
>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
>>>> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
>>>>
>>> This seems to be problem with your installation, you probably have diferen version of dmd compiler and phobos library. So you should uninstall all your dmd packages and make sure there is no /usr/include/dmd left in your system. And instal dmd only from one source (d-apt idealy).
>>>
>> I've done that 2 or 3 times.  If that's the problem, then there are different versions stored in the repository.  Since I'm on debian testing I'd been assuming that there'd been some system change since I'd last used the compiler, and the debs weren't yet up to date. The only updates to my system prior to the compiler breaking HAD been via apt-get.  Since then I've used dpkg remove and install a couple of times to try other versions of dmd with no benefit.
>> Currently dmd-bin version 2.071.2-0
>>               libphobos            2.071.2-0
>>               libphobos            2.071.2-0
>> so they're LISTED as being the same version.  And dmd.conf was installed by the deb, and is (eliminating the comments):
>> [Environment32]
>> DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L--export-dynamic
>>
>> [Environment64]
>> DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic
>>
>> But somewhere during the process (which included the nightly system update) the error messages changed, and now:
>> dmd test.d
>> yields:
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
>> ...
>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
>> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
> FWIW starting at /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121)::
>         asm nothrow @nogc
>         {
>             mov EDX, num;
>             lock;
>             inc _iSemLockCtrs[EDX * 2];
> so nothrow isn't being seen as appropriate at the beginning of an asm block.  After that I think it gets confused as 1123 doesn't HAVE a brace (i.e. curly bracket) in it.
>
when you type dmd --version what it prints?
October 31, 2016

On 10/31/2016 11:23 AM, Daniel Kozak via Digitalmars-d-learn wrote:
> Dne 31.10.2016 v 18:06 Charles Hixson via Digitalmars-d-learn napsal(a):
>>
>> On 10/31/2016 09:26 AM, Charles Hixson via Digitalmars-d-learn wrote:
>>> On 10/30/2016 11:34 PM, Daniel Kozak via Digitalmars-d-learn wrote:
>>>> Dne 31.10.2016 v 02:30 Charles Hixson via Digitalmars-d-learn napsal(a):
>>>>
>>>>>
>>>>> Well, that certainly changed the error messages.  With
>>>>> dmd -defaultlib=/usr/lib/x86_64-linux-gnu/libphobos2.so test.d
>>>>> I get:
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1124): Error: mismatched number of curly brackets
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1125): Error: mismatched number of curly brackets
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1126): Error: mismatched number of curly brackets
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1127): Error: mismatched number of curly brackets
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1128): Error: mismatched number of curly brackets
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1129): Error: mismatched number of curly brackets
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1133): Error: asm statements must end in ';'
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1136): Error: found 'private' instead of statement
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1146): Error: no identifier for declarator add
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: no identifier for declarator usDone
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1149): Error: Declaration expected, not ':'
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1157): Error: Declaration expected, not '('
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not 'foreach'
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1159): Error: Declaration expected, not '0'
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: no identifier for declarator __fhnd_info[fd]
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1164): Error: Declaration expected, not '='
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1165): Error: Declaration expected, not 'return'
>>>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
>>>>> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
>>>>>
>>>> This seems to be problem with your installation, you probably have diferen version of dmd compiler and phobos library. So you should uninstall all your dmd packages and make sure there is no /usr/include/dmd left in your system. And instal dmd only from one source (d-apt idealy).
>>>>
>>> I've done that 2 or 3 times.  If that's the problem, then there are different versions stored in the repository.  Since I'm on debian testing I'd been assuming that there'd been some system change since I'd last used the compiler, and the debs weren't yet up to date. The only updates to my system prior to the compiler breaking HAD been via apt-get.  Since then I've used dpkg remove and install a couple of times to try other versions of dmd with no benefit.
>>> Currently dmd-bin version 2.071.2-0
>>>               libphobos            2.071.2-0
>>>               libphobos            2.071.2-0
>>> so they're LISTED as being the same version.  And dmd.conf was installed by the deb, and is (eliminating the comments):
>>> [Environment32]
>>> DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/i386-linux-gnu -L--export-dynamic
>>>
>>> [Environment64]
>>> DFLAGS=-I/usr/include/dmd/phobos -I/usr/include/dmd/druntime/import -L-L/usr/lib/x86_64-linux-gnu -L--export-dynamic
>>>
>>> But somewhere during the process (which included the nightly system update) the error messages changed, and now:
>>> dmd test.d
>>> yields:
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121): Error: found 'nothrow' when expecting '{'
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1123): Error: mismatched number of curly brackets
>>> ...
>>> /usr/include/dmd/druntime/import/core/stdc/stdio.d(1167): Error: unrecognized declaration
>>> /usr/include/dmd/phobos/std/typecons.d(1124): Error: semicolon expected following function declaration
>> FWIW starting at /usr/include/dmd/druntime/import/core/stdc/stdio.d(1121)::
>>         asm nothrow @nogc
>>         {
>>             mov EDX, num;
>>             lock;
>>             inc _iSemLockCtrs[EDX * 2];
>> so nothrow isn't being seen as appropriate at the beginning of an asm block.  After that I think it gets confused as 1123 doesn't HAVE a brace (i.e. curly bracket) in it.
>>
> when you type dmd --version what it prints?
>
THAT WAS THE CLUE!
(that which follows is how I proceeded to the answer after that clue.)
 dmd -version
Error: unrecognized switch '-version'
and
dmd --version
Error: unrecognized switch '--version'
but
 dmd
DMD64 D Compiler v2.066.1

So thanks, that was the clue that I needed to fix the current problem.  (Once I have I'll probably be back where I started, but that's not certain.  That 2.066..stuff is one of my attempts to investigate what exactly was causing the problems, which must not have gotten completely uninstalled.

Yeah, now I'm back to:
...
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libphobos2.a(aaA_4f5_2d5.o): relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
...

and
dmd -defaultlib=libphobos2.so test.d
yeielding
/usr/bin/ld: test.o: relocation R_X86_64_32 against symbol `__dmd_personality_v0' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: error: ld returned 1 exit status
--- errorlevel 1

but
dmd -defaultlib=libphobos2.so -fPIC test.d
works.  It shouldn't be required (as in the default /etc/dmd.conf should handle it correctly, but I can deal with it now.

Copyright (c) 1999-2014 by Digital Mars written by Walter Bright
Documentation: http://dlang.org/


« First   ‹ Prev
1 2