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

Building the library for 32-bit architectures #212

Open
gnzlbg opened this issue Aug 15, 2018 · 11 comments
Open

Building the library for 32-bit architectures #212

gnzlbg opened this issue Aug 15, 2018 · 11 comments

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Aug 15, 2018

I am trying to build the library for i686-apple-darwin and i686-unknown-linux-gnu targets (generic 32-bit apple and linux targets).

The "Environment support matrix" says that 32-bit linux is supported, yet I cannot find a 32-bit linux travis or jenkins buildbot on CI (maybe this one https://github.com/shibatch/sleef/blob/master/Jenkinsfile#L70 ?) to see the steps involved.

The usual way to do this on Linux is to use a gcc-multilib package that comes with 32-bit libraries, and passing -march=i686, -m32, etc. to the compiler via CFLAGS, or in this case, CMAKE_C_FLAGS, but for some reason CMAKE_C_FLAGS appears to be completely ignored by the build system :/

Any ideas of what I am doing wrong?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 15, 2018

A reproducer is to just pass CMAKE_C_FLAGS="-m32" to the build. On all platforms where I've tried, the build configures fine, and starts building, but no compiler invocations contain -m32. Trying then to link the library to a 32-bit binary will fail.

@fpetrogalli
Copy link
Collaborator

fpetrogalli commented Aug 15, 2018 via email

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 15, 2018

You could also try invoking cmake as follows?

$> CFLAGS="-m32” cmake path/to/sleef

Same issue :/

IIRC cmake gets the CFLAGS and puts them into CMAKE_C_FLAGS automatically, which is what it then uses to set the flags of the C compiler.

I've managed to get the CMAKE_TOOLCHAIN_FILE working in other architectures, but I kind of wish that it was possible to do all this without such a file. I haven't tried to use a CMAKE_TOOLCHAIN_FILE for 32-bit architectures though, although that might work (IIRC the "list" variables there are "special", but I haven't used CMake in a long time).

--

That is, I'd expect that setting the usual suspects (CC, CFLAGS, LD, AR, HOST, TARGET, etc.) should be enough to properly cross-compile the library to any target without having to use a toolchain file, although using one should also be possible and supported.

@fpetrogalli
Copy link
Collaborator

fpetrogalli commented Aug 15, 2018 via email

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 15, 2018

while for SLEEF we have to set them for each target, so they are kinda hardcoded in the configuration.

The thing I don't yet understand is, why doesn't SLEEF append these to CMAKE_C_FLAGS ? Or the otherway around, append CMAKE_C_FLAGS to these while building the SLEEF binaries?

@fpetrogalli
Copy link
Collaborator

fpetrogalli commented Aug 15, 2018 via email

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 15, 2018

I hope I'll fix this tomorrow morning, now that the issue is confirmed, it shouldn't be too hard :)

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 16, 2018

So I think I fixed this already, but then SLEEF fails to build on i686-apple-darwin because... it does not define __SSE__, which seems to be a clang bug: https://bugs.llvm.org/show_bug.cgi?id=38594

So the configure should probably detect that target, and just error until a clang version is released with a fix...

@fpetrogalli
Copy link
Collaborator

@gnzlbg , do you have a patch showing the problem? I would like to reproduce it on my mac.

@shibatch
Copy link
Owner

I am going to add testing for 32-bit x86 and FreeBSD.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Aug 17, 2018 via email

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