Jump to page: 1 2
Thread overview
Cross compiling from windows targetting linux armel arm9
Dec 12, 2016
Sai
Dec 12, 2016
kink
Dec 12, 2016
Sai
Dec 12, 2016
kinke
Dec 25, 2016
Sai
Dec 25, 2016
Nicholas Wilson
Dec 25, 2016
Sai
Feb 16, 2017
Sai
Feb 16, 2017
kinke
Feb 17, 2017
Sai
Feb 17, 2017
kinke
Feb 17, 2017
Sai
December 12, 2016
As mentioned in the subject, I am trying to compile from windows os targetting linux arm9 (armel) arch.

There used to be a link to the binary ldc2 compiler to do this, but now I am unable to find that link. Is it not supported anymore? or the link just moved to a new place and I am unable to find it? Any help would be appreciated.

I am using windows os as it's a work PC and cannot install linux.

Thanks
Sai


December 12, 2016
On Monday, 12 December 2016 at 04:49:33 UTC, Sai wrote:
> There used to be a link to the binary ldc2 compiler to do this

The Windows binaries are available, and cross-compilation works as usual with `-mtriple=...`. This will allow you to generate object files. You'll need to figure out how to build druntime-ldc and phobos2-ldc for your target and then how to link your cross-compiled objects against those libs and the C runtime (e.g., building LDC yourself for armel and using that for native linking?).
I don't think there ever was an LDC binary automating some of this, please correct me if I'm wrong.
December 12, 2016
On Monday, 12 December 2016 at 09:34:42 UTC, kink wrote:
> On Monday, 12 December 2016 at 04:49:33 UTC, Sai wrote:
>> There used to be a link to the binary ldc2 compiler to do this
>
> The Windows binaries are available, and cross-compilation works as usual with `-mtriple=...`. This will allow you to generate object files. You'll need to figure out how to build druntime-ldc and phobos2-ldc for your target and then how to link your cross-compiled objects against those libs and the C runtime (e.g., building LDC yourself for armel and using that for native linking?).
> I don't think there ever was an LDC binary automating some of this, please correct me if I'm wrong.

Oh, I guess I remembered incorrectly. But I am positive it worked out of the box in linux though, using the default ldc2 that gets installed by apt-get. I tested that using another computer. But I wish it also worked out of the box in windows.

This is mainly for programming the EV3 lego mindstorm brick. Don't know if I can/want to build druntime now, I also don't have visual studio, etc.


December 12, 2016
On Monday, 12 December 2016 at 16:57:36 UTC, Sai wrote:
> Don't know if I can/want to build druntime now, I also don't have visual studio, etc.

Visual Studio is exactly what you don't need, since you don't target Windows. You need a linker (in your case most likely a Windows executable) able to target your ARM platform, and the libs. A matching GCC+binutils cross-compilation package (http://gnutoolchains.com/arm-eabi/ maybe) should work.
You can then cross-compile the druntime objects and archive them manually to a static lib if need be.
December 25, 2016
On Monday, 12 December 2016 at 22:54:43 UTC, kinke wrote:
> On Monday, 12 December 2016 at 16:57:36 UTC, Sai wrote:
>> Don't know if I can/want to build druntime now, I also don't have visual studio, etc.
>
> Visual Studio is exactly what you don't need, since you don't target Windows. You need a linker (in your case most likely a Windows executable) able to target your ARM platform, and the libs. A matching GCC+binutils cross-compilation package (http://gnutoolchains.com/arm-eabi/ maybe) should work.
> You can then cross-compile the druntime objects and archive them manually to a static lib if need be.


I finally managed to install virtualbox and lubuntu.
Now I get the following errors. Please help?


$ cat t.d
import std.stdio;

int main(string[] args) {
	writefln("Hello world!");
	return 0;
}


$ ldc2 t.d
/usr/bin/ld: t.o: relocation R_X86_64_32 against `.rodata.str1.1' 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
Error: /usr/bin/gcc failed with status: 1


$ gdc t.d
/usr/include/d/core/stdc/stdarg.d:48:23: error: undefined identifier '__va_list_tag'
     alias __va_list = __va_list_tag;
                       ^

$ ldc2 -no-pie t.d
ldc2: Unknown command line argument '-no-pie'.  Try: 'ldc2 -help'
ldc2: Did you mean '-noasm'?

$ gdc  -no-pie t.d
/usr/include/d/core/stdc/stdarg.d:48:23: error: undefined identifier '__va_list_tag'
     alias __va_list = __va_list_tag;




December 25, 2016
On Sunday, 25 December 2016 at 01:25:12 UTC, Sai wrote:
> $ ldc2 t.d
> /usr/bin/ld: t.o: relocation R_X86_64_32 against

Are you still trying to target arm? why is R_X86_64_32 appearing.

> `.rodata.str1.1' 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
> Error: /usr/bin/gcc failed with status: 1
>
>
> $ gdc t.d
> /usr/include/d/core/stdc/stdarg.d:48:23: error: undefined identifier '__va_list_tag'
>      alias __va_list = __va_list_tag;
>                        ^
>
> $ ldc2 -no-pie t.d
> ldc2: Unknown command line argument '-no-pie'.  Try: 'ldc2 -help'
> ldc2: Did you mean '-noasm'?

try the `-relocation-model` flag (look at the help)

>
> $ gdc  -no-pie t.d
> /usr/include/d/core/stdc/stdarg.d:48:23: error: undefined identifier '__va_list_tag'
>      alias __va_list = __va_list_tag;

December 25, 2016
On Sunday, 25 December 2016 at 05:35:05 UTC, Nicholas Wilson wrote:
> On Sunday, 25 December 2016 at 01:25:12 UTC, Sai wrote:
>> $ ldc2 t.d
>> /usr/bin/ld: t.o: relocation R_X86_64_32 against
>
> Are you still trying to target arm? why is R_X86_64_32 appearing.
>
>> `.rodata.str1.1' 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
>> Error: /usr/bin/gcc failed with status: 1
>>
>>
>> $ gdc t.d
>> /usr/include/d/core/stdc/stdarg.d:48:23: error: undefined identifier '__va_list_tag'
>>      alias __va_list = __va_list_tag;
>>                        ^
>>
>> $ ldc2 -no-pie t.d
>> ldc2: Unknown command line argument '-no-pie'.  Try: 'ldc2 -help'
>> ldc2: Did you mean '-noasm'?
>
> try the `-relocation-model` flag (look at the help)
>
>>
>> $ gdc  -no-pie t.d
>> /usr/include/d/core/stdc/stdarg.d:48:23: error: undefined identifier '__va_list_tag'
>>      alias __va_list = __va_list_tag;


Yes, I am still targeting ARM, but for initial development I will be compiling to x86_64 just to simplify coding and testing of the logic, I will be using sw simulators to emulate the robot.

Thanks for the tip, I will try that flag shortly.



February 16, 2017
>>
>> try the `-relocation-model` flag (look at the help)
>>

This used to work, but after updating to LDC 1.1.0, it stopped working, now I get this error:


sai@saivb:~/tmp$ ldc2 t.d
/usr/bin/ld: /home/sai/Programs/ldc2-1.1.0-linux-x86_64/bin/../lib/libdruntime-ldc.a(errno.c.o): relocation R_X86_64_PC32 against symbol `__errno_location@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1


sai@saivb:~/tmp$ ldc2 -relocation-model=dynamic-no-pic  t.d
/usr/bin/ld: /home/sai/Programs/ldc2-1.1.0-linux-x86_64/bin/../lib/libdruntime-ldc.a(errno.c.o): relocation R_X86_64_PC32 against symbol `__errno_location@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1


Any help is appreciated.
Testing on Ubuntu 16.10 with all updates installed.



February 16, 2017
On Thursday, 16 February 2017 at 16:57:56 UTC, Sai wrote:
> Any help is appreciated.
> Testing on Ubuntu 16.10 with all updates installed.

-relocation-model=pic ?
February 17, 2017
On Thursday, 16 February 2017 at 17:47:28 UTC, kinke wrote:
> On Thursday, 16 February 2017 at 16:57:56 UTC, Sai wrote:
>> Any help is appreciated.
>> Testing on Ubuntu 16.10 with all updates installed.
>
> -relocation-model=pic ?


I tried that too, but no luck :-(

sai@saivb:~/tmp$ ldc2 -relocation-model=pic t.d
/usr/bin/ld: /home/sai/Programs/ldc2-1.1.0-linux-x86_64/bin/../lib/libdruntime-ldc.a(errno.c.o): relocation R_X86_64_PC32 against symbol `__errno_location@@GLIBC_2.2.5' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1


BTW:

sai@saivb:~/tmp$ cat t.d
import std.stdio;

int main(string[] args) {
	writefln("Hello world!");
	return 0;
}




« First   ‹ Prev
1 2