strange -fPIC compilation error

Charles Hixson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Oct 31 12:20:21 PDT 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/




More information about the Digitalmars-d-learn mailing list