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

libgit2 cross-compile failure #10010

Closed
vtjnash opened this issue Feb 1, 2015 · 5 comments
Closed

libgit2 cross-compile failure #10010

vtjnash opened this issue Feb 1, 2015 · 5 comments
Labels
domain:building Build system, or building Julia or its dependencies

Comments

@vtjnash
Copy link
Sponsor Member

vtjnash commented Feb 1, 2015

libgit2 doesn't compile correctly for x86 on 64-bit.

here's a start at patching it:

diff --git a/Make.inc b/Make.inc
index ccf6cbd..a926e7a 100644
--- a/Make.inc
+++ b/Make.inc
@@ -464,9 +464,9 @@ endif
 # Set some ARCH-specific flags
 ifneq ($(USEICC),1)
 ifneq ($(ARCH), arm)
-CC += -m$(BINARY)
-CXX += -m$(BINARY)
-FC += -m$(BINARY)
+CC_ARG += -m$(BINARY)
+CXX_ARG += -m$(BINARY)
+FC_ARG += -m$(BINARY)
 endif
 endif

@@ -789,6 +789,10 @@ LDFLAGS += -cxxlib-nostd -static-intel
 endif
 endif

+CC += $(CC_ARG)
+CXX += $(CXX_ARG)
+FC += $(FC_ARG)
+
 # Make tricks

 define dir_target
diff --git a/README.md b/README.md
index 8fd94fe..2985c32 100644
--- a/README.md
+++ b/README.md
@@ -187,7 +187,7 @@ Julia does not install anything outside the directory it was cloned into. Julia

 Julia can be built for a non-generic architecture by configuring the `ARCH` Makefile variable. See the appropriate section of `Make.inc` for additional customization options, such as `MARCH` and `JULIA_CPU_TARGET`.

-For example, to build for Pentium 4, set `MARCH=pentium4` and install the necessary system libraries for linking. On Ubuntu, these may include lib32gfortran3 (also manually call `ln -s /usr/lib32/libgfortran3.so.0 /usr/lib32/libgfortran3.so`) and lib32gcc1, lib32stdc++6, among others.
+For example, to build for Pentium 4, set `MARCH=pentium4` and install the necessary system libraries for linking. On Ubuntu, these may include `lib32gfortran3` (also manually call `ln -s /usr/lib32/libgfortran3.so.0 /usr/lib32/libgfortran3.so`) and `lib32gcc1`, `lib32stdc++6`, `lib32z1-dev`, among others.

 You can also set `MARCH=native` for a maximum-performance build customized for the current machine CPU.

diff --git a/deps/Makefile b/deps/Makefile
index c42036c..e851ac6 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -20,11 +20,11 @@ CMAKE_COMMON += -DCMAKE_VERBOSE_MAKEFILE=ON
 endif
 CMAKE_COMMON += -DCMAKE_C_COMPILER="$(CC_BASE)"
 ifdef CC_ARG
-CMAKE_COMMON += -DCMAKE_C_COMPILER_ARG1="$(CC_ARG)"
+CMAKE_COMMON += -DCMAKE_C_FLAGS="$(CC_ARG)"
 endif
 CMAKE_COMMON += -DCMAKE_CXX_COMPILER="$(CXX_BASE)"
 ifdef CXX_ARG
-CMAKE_COMMON += -DCMAKE_CXX_COMPILER_ARG1="$(CXX_ARG)"
+CMAKE_COMMON += -DCMAKE_CXX_FLAGS="$(CXX_ARG)"
 endif

 # If the top-level Makefile is called with environment variables,

but cmake seems to get very confused that it isn't using the system libraries/headers/compiler and it ends up computing the dependency locations wrong.

@vtjnash vtjnash added the domain:building Build system, or building Julia or its dependencies label Feb 1, 2015
@vtjnash vtjnash changed the title libgit2 cross-compile libgit2 cross-compile failure Feb 1, 2015
@tkelman
Copy link
Contributor

tkelman commented Feb 2, 2015

Yeah, cmake is kind of a pain with cross-compiling. You need a whole bunch of flags to tell it to look in a different sysroot, and not check the usual locations. The Linux-to-Windows cross-compile of libgit2 does work, so something similar could possibly be made to work here.

Though note this also might break USE_CCACHE.

@vtjnash
Copy link
Sponsor Member Author

vtjnash commented Feb 2, 2015

yeah, although it looks like it works mostly because it's heavily hacked into the libgit2 file. it's unfortunate that autoconf actually seems to be incredibly good at this, while cmake is so incredibly awful at it.

@tkelman
Copy link
Contributor

tkelman commented Feb 2, 2015

Right, cross-compiling is probably cmake's biggest weakness as far as I'm concerned. I think what people commonly do is use a toolchain file where they start throwing all the flags they end up needing for cross-compiling. Or on the opensuse build service they've got some convenient mingw64_cmake spec macros that expand out to all the flags you need.

tkelman added a commit that referenced this issue Apr 29, 2015
mbauman pushed a commit to mbauman/julia that referenced this issue Jun 6, 2015
multilib does still confuse cmake when it comes to finding openssl
you will likely need to install libssl-dev:i386
@tkelman
Copy link
Contributor

tkelman commented Jun 17, 2015

(whoops, put this in the wrong place, moved from #11021) looks like Ubuntu has a convenient MultiArchCross.cmake toolchain file that we could set a bunch of DEB_BUILD_GNU_TYPE etc environment variables to activate and it might fix this, but I can't see any signs of that file having been upstreamed from Ubuntu to Debian or from Debian to cmake. Check /usr/share/cmake-*/Modules to see if it's there on Debian.

@tkelman
Copy link
Contributor

tkelman commented Jun 17, 2015

@garrison I just tried this in a docker container of Ubuntu 15.04 (had to run dpkg --add-architecture i386) and it's actually fixed automatically there. That multiarch toolchain file must be getting used automatically by Ubuntu's copy of cmake. I get this output during the configuration step of libgit2:

-- Found OpenSSL: /usr/lib/i386-linux-gnu/libssl.so;/usr/lib/i386-linux-gnu/libcrypto.so (found version "1.0.1f")

Might be worth bothering the Debian maintainer of cmake to adopt the setup that Ubuntu is using, since it works. There might be an open Debian bug about it already, I'd have to look.

edit: nevermind, you need to temporarily uninstall/rename pkg-config, or figure out how to tell cmake not to use it - it works properly when pkg-config is not installed, but fails if it is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
domain:building Build system, or building Julia or its dependencies
Projects
None yet
Development

No branches or pull requests

2 participants