openssl: 1.1.1 fails to build with MUSL libc due to missing linux/mman.h
Building OpenSSL 1.1.1 against MUSL libc fails to find the linux/mman.h header:
$ curl -L https://www.openssl.org/source/openssl-1.1.1.tar.gz | tar --strip-components=1 -xzf -
$ export CC=musl-gcc
$ ./Configure --prefix=$OPENSSL_DIR linux-x86_64 no-shared no-async no-engine
$ make
[...]
musl-gcc -I. -Icrypto/include -Iinclude -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPADLOCK_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/openssl/ssl\"" -DENGINESDIR="\"/openssl/lib/engines-1.1\"" -DNDEBUG -MMD -MF crypto/mem_sec.d.tmp -MT crypto/mem_sec.o -c -o crypto/mem_sec.o crypto/mem_sec.c
crypto/mem_sec.c:37:27: fatal error: linux/mman.h: No such file or directory
# include <linux/mman.h>
^
compilation terminated.
CC="musl-gcc" /usr/bin/perl crypto/modes/asm/aesni-gcm-x86_64.pl elf crypto/modes/aesni-gcm-x86_64.s
Makefile:3816: recipe for target 'crypto/mem_sec.o' failed
make[1]: *** [crypto/mem_sec.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/tmp/openssl_build'
Makefile:171: recipe for target 'all' failed
make: *** [all] Error 2
The same build setup does work with 1.1.0. This is using the musl-tools package on Debian Stretch.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 19 (11 by maintainers)
Commits related to this issue
- Install linux-headers, as required for OpenSSL 1.1.1 (https://github.com/openssl/openssl/issues/7207) — committed to madars/zcash-docker by madars 5 years ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to curl/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to curl/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
- install musl packages for linux `linux-headers` package required to fix openssl builds to avoid: ``` ../crypto/mem_sec.c:60:13: fatal error: linux/mman.h: No such file or directory 60 | # includ... — committed to vszakats/curl-for-win by vszakats 10 months ago
On alpine I do an
apk add linux-headersI found a workaround on ubuntu, without needing to disable secure memory!
I added
-static -idirafter /usr/include/ -idirafter /usr/include/x86_64-linux-gnu/to my musl-gcc command.For reference, here’s the complete set of steps I used to build openssl against musl in a github actions ubuntu CI runner:
this compiled the openssl libraries and makes all the files available in the /musl directory.
To make user of it as a dependency on another build (ie the rust openssl-sys create), i added the following env vars to that build:
Hope someone else finds this useful
If your build pipeline for Linux runs under the Arch Linux OS, you can install
kernel-headers-musl. This works for me, and is better in that we keep the secure memory feature.