mailing list of musl libc
 help / color / mirror / code / Atom feed
* Compiling 32bit executables on 64bit system with MUSL
@ 2018-09-02 13:01 John Found
  2018-09-02 15:18 ` Szabolcs Nagy
  0 siblings, 1 reply; 3+ messages in thread
From: John Found @ 2018-09-02 13:01 UTC (permalink / raw)
  To: musl

[-- Attachment #1: Type: text/plain, Size: 1436 bytes --]

I was able to do it before, although with some hassle and questions in the mailing list.
But today I tried again and it seems the old tricks does not work now.

What I am doing:

1. Compile and install MUSL for i386:

$ sudo ln -s /usr/bin/ar /usr/bin/i386-ar
$ sudo ln -s /usr/bin/ranlib /usr/bin/i386-ranlib
$ ./configure --host=i386 CC="gcc -m32"
$ make
$ sudo make install

2. edit the file /usr/local/musl/bin/musl-gcc (removing double quotes):

exec ${REALGCC:-gcc -m32} "$@" -specs "/usr/local/musl/lib/musl-gcc.specs"

3. Change the file /usr/local/musl/lib/musl-gcc.specs to the attached in this message.

As I said, this procedure happened to work before. 
But now, when trying to compile some file, the compilation failed with linker error message.

Here is some simple test:

$cat ./hello.c 
#include <stdio.h>
int main()
{
   printf("Hello, World!");
   return 0;
}

$musl-gcc -o hello ./hello.c
/usr/bin/ld: /usr/lib/gcc/x86_64-pc-linux-gnu/8.2.0/32/crtbegin.o: direct GOT relocation R_386_GOT32X against `_ITM_deregisterTMCloneTable' without base register can not be used when making a shared object
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status

Actually my C programming skills are very low, so I can't even understand what the linker is talking about.

The version of GCC is 8.2.0; 

Any help will be appreciated!
-- 
John Found
https://board.asm32.info

[-- Attachment #2: musl-gcc.specs --]
[-- Type: application/octet-stream, Size: 721 bytes --]

*asm:
--32

%rename cpp_options old_cpp_options

*cpp_options:
-nostdinc -isystem /usr/local/musl/include -isystem include%s %(old_cpp_options)

*cc1:
%(cc1_cpu) -m32 -nostdinc -isystem /usr/local/musl/include -isystem include%s

*link_libgcc:
-L/usr/local/musl/lib -L .%s

*libgcc:
32/libgcc.a%s %:if-exists(32/libgcc_eh.a%s)

*startfile:
%{!shared: /usr/local/musl/lib/%{pie:S}crt1.o} /usr/local/musl/lib/crti.o %{shared|pie:crtbeginS.o%s;:32/crtbegin.o%s}

*endfile:
%{shared|pie:crtendS.o%s;:32/crtend.o%s} /usr/local/musl/lib/crtn.o

*link:
-m elf_i386 -dynamic-linker /lib/ld-musl-i386.so.1 -nostdlib %{shared:-shared} %{static:-static} %{rdynamic:-export-dynamic}

*esp_link:


*esp_options:


*esp_cpp_options:



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-09-02 16:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-02 13:01 Compiling 32bit executables on 64bit system with MUSL John Found
2018-09-02 15:18 ` Szabolcs Nagy
2018-09-02 16:11   ` John Found

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).