www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Cross compiling from windows targetting linux armel arm9

reply Sai <tmp tmp.com> writes:
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
Dec 11 2016
parent reply kink <noone nowhere.com> writes:
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.
Dec 12 2016
parent reply Sai <tmp tmp.com> writes:
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.
Dec 12 2016
parent reply kinke <noone nowhere.com> writes:
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.
Dec 12 2016
parent reply Sai <tmp tmp.com> writes:
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;
Dec 24 2016
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
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;
Dec 24 2016
parent reply Sai <t t.c> writes:
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.
Dec 25 2016
parent reply Sai <tmp tmp.com> writes:
 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/libdrunti e-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/libdrunti e-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.
Feb 16 2017
parent reply kinke <noone nowhere.com> writes:
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 ?
Feb 16 2017
parent reply Sai <tmp tmp.com> writes:
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/libdrunti e-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; }
Feb 16 2017
parent reply kinke <noone nowhere.com> writes:
On Friday, 17 February 2017 at 02:10:41 UTC, Sai wrote:
 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/libdrunti e-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; }
Your linker complains about druntime not having been compiled with `-relocation-model=pic`. If PIC is mandatory for Ubuntu 16.10, even for executables and not just shared objects, then you'd need to recompile druntime/Phobos yourself. But I'd first look into your command-line flags/config file, as the error message is rather strange, you probably want an executable and not a DLL.
Feb 17 2017
parent Sai <tmp tmp.com> writes:
On Friday, 17 February 2017 at 09:12:36 UTC, kinke wrote:
 On Friday, 17 February 2017 at 02:10:41 UTC, Sai wrote:
 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/libdrunti e-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; }
Your linker complains about druntime not having been compiled with `-relocation-model=pic`. If PIC is mandatory for Ubuntu 16.10, even for executables and not just shared objects, then you'd need to recompile druntime/Phobos yourself. But I'd first look into your command-line flags/config file, as the error message is rather strange, you probably want an executable and not a DLL.
I am getting the feeling that LDC is not ready for newbies/hobbyists. I am thinking may be I should stick with previous version for now. I guess I can always fall back to C++ if this does not work.
Feb 17 2017