Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linkerscript not supported #131

Closed
stackTom opened this issue Jun 7, 2020 · 7 comments
Closed

Linkerscript not supported #131

stackTom opened this issue Jun 7, 2020 · 7 comments

Comments

@stackTom
Copy link

stackTom commented Jun 7, 2020

I am trying to build GNU GMP on Windows 64 bit x86 host for ARM64. However, linkerscript file isn’t supported (as per the readme as well). However, https://lld.llvm.org/# states that LLD is a drop in replacement for GNU LD and that it supports the same linker scripts. Is there any way to get the tool chain to support linkerscript?

@mati865
Copy link
Contributor

mati865 commented Jun 7, 2020

lld.llvm.org/# states that LLD is a drop in replacement for GNU LD and that it supports the same linker scripts.

This part is only true for ELF backend. MinGW implementation doesn't support them.


IIRC GMP build process doesn't use linker scripts. You probably have non-patched version of libtool, see https://github.com/mstorsjo/llvm-mingw#known-issues

@stackTom
Copy link
Author

stackTom commented Jun 7, 2020

lld.llvm.org/# states that LLD is a drop in replacement for GNU LD and that it supports the same linker scripts.

This part is only true for ELF backend. MinGW implementation doesn't support them.


IIRC GMP build process doesn't use linker scripts. You probably have non-patched version of libtool, see https://github.com/mstorsjo/llvm-mingw#known-issues

Got it, thanks. GMP uses linker scripts to pass in the list of object files to link. I modified libtool.sh to set the variable “with_gnu_ld” to “no” and it was able to get farther in the linking process as it stopped using linkerscript to pass object files to ld-link.

How would I get a patched version of libtool, as I am not sure if my libtool.sh hack will cause problems down the line?

@mati865
Copy link
Contributor

mati865 commented Jun 7, 2020

How would I get a patched version of libtool, as I am not sure if my libtool.sh hack will cause problems down the line?

It depends. On Windows MSYS2 provides patched libtool, on Arch Linux you can use this AUR package and finally you can build libtool yourself with those 2 patches: 1 and 2 I don't know if other patches are necessary on Linux.

@stackTom
Copy link
Author

stackTom commented Jun 7, 2020

How would I get a patched version of libtool, as I am not sure if my libtool.sh hack will cause problems down the line?

It depends. On Windows MSYS2 provides patched libtool, on Arch Linux you can use this AUR package and finally you can build libtool yourself with those 2 patches: 1 and 2 I don't know if other patches are necessary on Linux.

Got it. I am building gmp with msys2 MINGW64, so that means I am using the patched libtool. Or is there something I have to do activate to use it?

@mstorsjo
Copy link
Owner

mstorsjo commented Jun 7, 2020

libtool is embedded in each source package (if you unpack a source tarball and build it, you normally don't need libtool installed on your system, as it uses a copy bundled in the tarball).

Rerun autoreconf -fi in the unpacked source directory, and it should update the bundled libtool with the patched one from your system.

@stackTom
Copy link
Author

stackTom commented Jun 7, 2020

libtool is embedded in each source package (if you unpack a source tarball and build it, you normally don't need libtool installed on your system, as it uses a copy bundled in the tarball).

Rerun autoreconf -fi in the unpacked source directory, and it should update the bundled libtool with the patched one from your system.

I installed libtool with: pacman -S mingw-w64-x86_64-libtool
Then, I ran ./configure --disable-static --enable-shared --enable-cxx --prefix=/GMP_BUILD --host=aarch64-w64-mingw32
Then, I installed autoreconf with pacman -S autoconf automake
Then, I ran autoreconf -fi, inside the gmp directory but get the error: previous directory /i/llvm-mingw/BUILDDDD/bin/gmp-6.2.0 changed before entering /tmp/arX1MY26/am4tpJAI1J, expected dev=335552895 ino=59954170039419509, actual dev=1479620138 ino=11359192701075667225, aborting. at /usr/share/autoconf/Autom4te/General.pm line 196.

So, I decided to simply copy over the newly installed libtool from mingw to overwrite the libtool in the gmp build directory, but now get errors like this: lld-link: error: .libs\assert.o: machine type arm64 conflicts with x64

Any help is appreciated :).

@stackTom
Copy link
Author

stackTom commented Jun 8, 2020

Update:
I have re downloaded GMP, and followed these steps:

  1. untar the gmp package
  2. run autoreconf -fi inside the gmp main directory that was untarred in 1)
  3. configured and make as above...

It works now :). Thanks for your help and for your excellent work with llvm-mingw.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants