rumpkernel / rumprun-packages

Ready-made packages of software for running on the Rumprun unikernel
Other
203 stars 79 forks source link

Error compiling Python (libressl): error: 'KERN_ARND' undeclared #149

Open hfingler opened 5 years ago

hfingler commented 5 years ago

I'm running into the same issues as #109

I compiled rumprun (CC=cc ./build-rr.sh xen), exported RUMPRUN_TOOLCHAIN_TUPLE=x86_64-rumprun-netbsd (output below), cloned this repo and was following the python README. When I run make I get the following error:

 $make
make -C ../libressl
make[1]: Entering directory '/home/hfingler/rumprun-packages/libressl'
make -C build
make[2]: Entering directory '/home/hfingler/rumprun-packages/libressl/build'
Making all in crypto
make[3]: Entering directory '/home/hfingler/rumprun-packages/libressl/build/crypto'
  CC       compat/getentropy_netbsd.lo
compat/getentropy_netbsd.c: In function 'getentropy_sysctl':
compat/getentropy_netbsd.c:39:11: error: 'KERN_ARND' undeclared (first use in this function)
  mib[1] = KERN_ARND;
           ^~~~~~~~~
compat/getentropy_netbsd.c:39:11: note: each undeclared identifier is reported only once for each function it appears in
Makefile:3615: recipe for target 'compat/getentropy_netbsd.lo' failed
make[3]: *** [compat/getentropy_netbsd.lo] Error 1
make[3]: Leaving directory '/home/hfingler/rumprun-packages/libressl/build/crypto'
Makefile:452: recipe for target 'all-recursive' failed
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory '/home/hfingler/rumprun-packages/libressl/build'
Makefile:9: recipe for target 'build/libressl' failed
make[1]: *** [build/libressl] Error 2
make[1]: Leaving directory '/home/hfingler/rumprun-packages/libressl'
../Makefile.deps:3: recipe for target '/home/hfingler/rumprun-packages/pkgs/lib/libssl.a' failed
make: *** [/home/hfingler/rumprun-packages/pkgs/lib/libssl.a] Error 2

Here's the output for the build:

>>
>> Finished ./build-rr.sh for xen
>>
>> For Rumprun developers (if you're not sure, you don't need it):
. "/home/hfingler/rumprun/./obj-amd64-xen/config"
>>
>> toolchain tuple: x86_64-rumprun-netbsd
>> cc wrapper: x86_64-rumprun-netbsd-gcc
>> installed to "/home/hfingler/rumprun/./rumprun"
>>
>> Set tooldir to front of $PATH (bourne-style shells)
. "/home/hfingler/rumprun/./obj-amd64-xen/config-PATH.sh"
>>
>> ./build-rr.sh ran successfully

Following one of the comments on the previous issues, I ran:

x86_64-rumprun-netbsd-gcc -print-sysroot, which gave me /home/hfingler/rumprun/./rumprun/rumprun-x86_64. I then opened /home/hfingler/rumprun/./rumprun/rumprun-x86_64/include/sys/sysctl.h and searched for KERN_ARND and it is defined there.

The offending file is including <sys/sysctl.h>.

Someone in that issue solved it by changing the libressl version, but that didn't work for me. I changed the version in UPSTREAM=http://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-2.4.2.tar.gz to 2.8.2 and 2.6.0; neither worked.

Can anyone help me fix this?

Thanks.

hfingler commented 5 years ago

I was able to make it compile by adding a CPPFLAG (based on the openjdk Makefile):

diff --git a/python3/Makefile b/python3/Makefile
index 7d8f8ab..0d4cef4 100644
--- a/python3/Makefile
+++ b/python3/Makefile
@@ -16,7 +16,7 @@ build/python: build/Makefile

 PYTHON_CONF_ENV += \
        LDFLAGS="-static -static-libgcc -L${RUMPRUN_PKGS_DIR}/lib" \
-       CPPFLAGS="$(CPPFLAGS) -static -I${RUMPRUN_PKGS_DIR}/include" \
+       CPPFLAGS="$(CPPFLAGS) -static -I${RUMPRUN_PKGS_DIR}/include -I${RUMPRUN_SYSROOT}/include" \
        CFLAGS="$(CFLAGS) -static" \
        CC=$(RUMPRUN_CC) \
        PYTHON_FOR_BUILD=$(shell pwd)/build/hostdist/bin/python3 \

Don't know if this is the final solution to this issue, so I'm not creating a PR for now. I'll create it if a dev says it's fine.