Merge pull request #112939 from symphorien/musl32cross

pkgsCross.musl32: fix a few basic package
This commit is contained in:
Guillaume Girol 2021-02-18 06:44:49 +00:00 committed by GitHub
commit 009d4570d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 134 additions and 10 deletions

View File

@ -0,0 +1,24 @@
From e7446c9bcb47674c9d0ee3b5bab129e9b86eb1c9 Mon Sep 17 00:00:00 2001
From: Walter Franzini <walter.franzini@gmail.com>
Date: Fri, 7 Jun 2019 17:57:11 +0200
Subject: [PATCH] musl does not support rewind pipe, make it build anyway
---
src/formats.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/formats.c b/src/formats.c
index f3efe764..477bf451 100644
--- a/src/formats.c
+++ b/src/formats.c
@@ -424,7 +424,6 @@ static void UNUSED rewind_pipe(FILE * fp)
/* To fix this #error, either simply remove the #error line and live without
* file-type detection with pipes, or add support for your compiler in the
* lines above. Test with cat monkey.wav | ./sox --info - */
- #error FIX NEEDED HERE
#define NO_REWIND_PIPE
(void)fp;
#endif
--
2.19.2

View File

@ -27,6 +27,8 @@ stdenv.mkDerivation rec {
# configure.ac uses pkg-config only to locate libopusfile # configure.ac uses pkg-config only to locate libopusfile
nativeBuildInputs = optional enableOpusfile pkg-config; nativeBuildInputs = optional enableOpusfile pkg-config;
patches = [ ./0001-musl-rewind-pipe-workaround.patch ];
buildInputs = buildInputs =
optional (enableAlsa && stdenv.isLinux) alsaLib ++ optional (enableAlsa && stdenv.isLinux) alsaLib ++
optional enableLibao libao ++ optional enableLibao libao ++

View File

@ -451,6 +451,8 @@ stdenv.mkDerivation {
hardening_unsupported_flags+=" stackprotector pic" hardening_unsupported_flags+=" stackprotector pic"
'' + optionalString (targetPlatform.libc == "newlib") '' '' + optionalString (targetPlatform.libc == "newlib") ''
hardening_unsupported_flags+=" stackprotector fortify pie pic" hardening_unsupported_flags+=" stackprotector fortify pie pic"
'' + optionalString (targetPlatform.libc == "musl" && targetPlatform.isx86_32) ''
hardening_unsupported_flags+=" stackprotector"
'' + optionalString targetPlatform.isNetBSD '' '' + optionalString targetPlatform.isNetBSD ''
hardening_unsupported_flags+=" stackprotector fortify" hardening_unsupported_flags+=" stackprotector fortify"
'' + optionalString cc.langAda or false '' '' + optionalString cc.langAda or false ''

View File

@ -78,7 +78,11 @@ let majorVersion = "6";
++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch
# Obtain latest patch with ../update-mcfgthread-patches.sh # Obtain latest patch with ../update-mcfgthread-patches.sh
++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch; ++ optional (!crossStageStatic && targetPlatform.isMinGW) ./Added-mcf-thread-model-support-from-mcfgthread.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isx86_32) (fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/main/gcc/gcc-6.1-musl-libssp.patch?id=5e4b96e23871ee28ef593b439f8c07ca7c7eb5bb";
sha256 = "1jf1ciz4gr49lwyh8knfhw6l5gvfkwzjy90m7qiwkcbsf4a3fqn2";
});
javaEcj = fetchurl { javaEcj = fetchurl {
# The `$(top_srcdir)/ecj.jar' file is automatically picked up at # The `$(top_srcdir)/ecj.jar' file is automatically picked up at

View File

@ -72,6 +72,10 @@ let majorVersion = "7";
}) })
++ optional langFortran ../gfortran-driving.patch ++ optional langFortran ../gfortran-driving.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch ++ optional (targetPlatform.libc == "musl" && targetPlatform.isPower) ../ppc-musl.patch
++ optional (targetPlatform.libc == "musl" && targetPlatform.isx86_32) (fetchpatch {
url = "https://git.alpinelinux.org/aports/plain/main/gcc/gcc-6.1-musl-libssp.patch?id=5e4b96e23871ee28ef593b439f8c07ca7c7eb5bb";
sha256 = "1jf1ciz4gr49lwyh8knfhw6l5gvfkwzjy90m7qiwkcbsf4a3fqn2";
})
++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch ++ optional (targetPlatform.libc == "musl") ../libgomp-dont-force-initial-exec.patch
# Obtain latest patch with ../update-mcfgthread-patches.sh # Obtain latest patch with ../update-mcfgthread-patches.sh

View File

@ -94,9 +94,6 @@ let
# In uclibc cases, libgomp needs an additional '-ldl' # In uclibc cases, libgomp needs an additional '-ldl'
# and as I don't know how to pass it, I disable libgomp. # and as I don't know how to pass it, I disable libgomp.
"--disable-libgomp" "--disable-libgomp"
] ++ lib.optionals (targetPlatform.libc == "musl") [
# musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865
"--disable-libmpx"
] ++ lib.optional (targetPlatform.libc == "newlib") "--with-newlib" ] ++ lib.optional (targetPlatform.libc == "newlib") "--with-newlib"
++ lib.optional (targetPlatform.libc == "avrlibc") "--with-avrlibc" ++ lib.optional (targetPlatform.libc == "avrlibc") "--with-avrlibc"
); );
@ -181,6 +178,9 @@ let
# On Illumos/Solaris GNU as is preferred # On Illumos/Solaris GNU as is preferred
"--with-gnu-as" "--without-gnu-ld" "--with-gnu-as" "--without-gnu-ld"
] ]
++ lib.optional (targetPlatform.libc == "musl")
# musl at least, disable: https://git.buildroot.net/buildroot/commit/?id=873d4019f7fb00f6a80592224236b3ba7d657865
"--disable-libmpx"
++ lib.optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [ ++ lib.optionals (targetPlatform == hostPlatform && targetPlatform.libc == "musl") [
"--disable-libsanitizer" "--disable-libsanitizer"
"--disable-symvers" "--disable-symvers"

View File

@ -0,0 +1,44 @@
--- Makefile.orig
+++ Makefile
@@ -23,24 +23,25 @@
# SUCH DAMAGE.
#
# $Id: Makefile,v 1.3 2004/07/19 05:19:55 sobomax Exp $
+#
+# Linux Makefile by Matt Smith <mcs@darkregion.net>, 2011/01/04
-LIB= execinfo
+CC=cc
+AR=ar
+EXECINFO_CFLAGS=$(CFLAGS) -O2 -pipe -fno-strict-aliasing -std=gnu99 -c
+EXECINFO_LDFLAGS=$(LDFLAGS)
-SRCS= stacktraverse.c stacktraverse.h execinfo.c execinfo.h
+all: static dynamic
-INCS= execinfo.h
+static:
+ $(CC) $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) stacktraverse.c
+ $(CC) $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) execinfo.c
+ $(AR) rcs libexecinfo.a stacktraverse.o execinfo.o
-SHLIB_MAJOR= 1
-SHLIB_MINOR= 0
+dynamic:
+ $(CC) -fpic -DPIC $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) stacktraverse.c -o stacktraverse.So
+ $(CC) -fpic -DPIC $(EXECINFO_CFLAGS) $(EXECINFO_LDFLAGS) execinfo.c -o execinfo.So
+ $(CC) -shared -Wl,-soname,libexecinfo.so.1 -o libexecinfo.so.1 stacktraverse.So execinfo.So
-NOPROFILE= yes
-
-DPADD= ${LIBM}
-LDADD= -lm
-
-#WARNS?= 4
-
-#stacktraverse.c: gen.py
-# ./gen.py > stacktraverse.c
-
-.include <bsd.lib.mk>
+clean:
+ rm -rf *.o *.So *.a *.so

View File

@ -23,14 +23,11 @@ stdenv.mkDerivation rec {
url = "https://git.alpinelinux.org/aports/plain/main/libexecinfo/20-define-gnu-source.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1"; url = "https://git.alpinelinux.org/aports/plain/main/libexecinfo/20-define-gnu-source.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1";
sha256 = "1mp8mc639b0h2s69m5z6s2h3q3n1zl298j9j0plzj7f979j76302"; sha256 = "1mp8mc639b0h2s69m5z6s2h3q3n1zl298j9j0plzj7f979j76302";
}) })
(fetchpatch { ./30-linux-makefile.patch
name = "30-linux-makefile.patch";
url = "https://git.alpinelinux.org/aports/plain/main/libexecinfo/30-linux-makefile.patch?id=730cdcef6901750f4029d4c3b8639ce02ee3ead1";
sha256 = "1jwjz22z5cjy5h2bfghn62yl9ar8jiqhdvbwrcfavv17ihbhwcaf";
})
]; ];
makeFlags = [ "CC:=$(CC)" "AR:=$(AR)" ]; makeFlags = [ "CC:=$(CC)" "AR:=$(AR)" ];
hardeningEnable = [ "stackprotector" ];
buildFlags = buildFlags =
lib.optional enableStatic "static" lib.optional enableStatic "static"

View File

@ -1,5 +1,5 @@
{ lib, stdenv, fetchurl, gettext, libgpgerror, enableCapabilities ? false, libcap { lib, stdenv, fetchurl, gettext, libgpgerror, enableCapabilities ? false, libcap
, buildPackages , buildPackages, fetchpatch
}: }:
assert enableCapabilities -> stdenv.isLinux; assert enableCapabilities -> stdenv.isLinux;
@ -13,6 +13,15 @@ stdenv.mkDerivation rec {
sha256 = "1nb50bgzp83q6r5cz4v40y1mcbhpqwqyxlay87xp1lrbkf5pm9n5"; sha256 = "1nb50bgzp83q6r5cz4v40y1mcbhpqwqyxlay87xp1lrbkf5pm9n5";
}; };
patches = [
# fix build on 32bit musl
(fetchpatch {
name = "fix_building_with_disable-asm_on_x86.patch";
url = "https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgcrypt.git;a=commitdiff_plain;h=af23ab5c5482d625ff52e60606cf044e2b0106c8";
sha256 = "1m8apm8wra6fk89ggha4d0bba5absihm38zvb2khklqh9q5hj9jw";
})
];
outputs = [ "out" "dev" "info" ]; outputs = [ "out" "dev" "info" ];
outputBin = "dev"; outputBin = "dev";
@ -27,6 +36,8 @@ stdenv.mkDerivation rec {
++ lib.optional stdenv.isDarwin gettext ++ lib.optional stdenv.isDarwin gettext
++ lib.optional enableCapabilities libcap; ++ lib.optional enableCapabilities libcap;
strictDeps = true;
configureFlags = [ "--with-libgpg-error-prefix=${libgpgerror.dev}" ] configureFlags = [ "--with-libgpg-error-prefix=${libgpgerror.dev}" ]
++ lib.optional stdenv.hostPlatform.isMusl "--disable-asm"; ++ lib.optional stdenv.hostPlatform.isMusl "--disable-asm";

View File

@ -12,6 +12,11 @@ stdenv.mkDerivation rec {
separateDebugInfo = stdenv.isLinux && stdenv.hostPlatform.libc != "musl"; separateDebugInfo = stdenv.isLinux && stdenv.hostPlatform.libc != "musl";
enableParallelBuilding = true; enableParallelBuilding = true;
hardeningDisable = lib.optional (stdenv.targetPlatform.isMusl && stdenv.targetPlatform.isx86_32) "stackprotector";
# FIXME: the hardeingDisable attr above does not seems effective, so
# the need to disable stackprotector via configureFlags
configureFlags = lib.optional (stdenv.targetPlatform.isMusl && stdenv.targetPlatform.isx86_32) "--disable-ssp";
doCheck = true; doCheck = true;

View File

@ -16,6 +16,11 @@ let
sha256 = "14igk6k00bnpfw660qhswagyhvr0gfqg4q55dxvaaq7ikfkrir71"; sha256 = "14igk6k00bnpfw660qhswagyhvr0gfqg4q55dxvaaq7ikfkrir71";
}; };
stack_chk_fail_local_c = fetchurl {
url = "https://git.alpinelinux.org/aports/plain/main/musl/__stack_chk_fail_local.c?h=3.10-stable";
sha256 = "1nhkzzy9pklgjcq2yg89d3l18jif331srd3z3vhy5qwxl1spv6i9";
};
# iconv tool, implemented by musl author. # iconv tool, implemented by musl author.
# Original: http://git.etalabs.net/cgit/noxcuse/plain/src/iconv.c?id=02d288d89683e99fd18fe9f54d4e731a6c474a4f # Original: http://git.etalabs.net/cgit/noxcuse/plain/src/iconv.c?id=02d288d89683e99fd18fe9f54d4e731a6c474a4f
# We use copy from Alpine which fixes error messages, see: # We use copy from Alpine which fixes error messages, see:
@ -87,6 +92,16 @@ stdenv.mkDerivation rec {
NIX_DONT_SET_RPATH = true; NIX_DONT_SET_RPATH = true;
preBuild = ''
${if (stdenv.targetPlatform.libc == "musl" && stdenv.targetPlatform.isx86_32) then
"# the -x c flag is required since the file extension confuses gcc
# that detect the file as a linker script.
$CC -x c -c ${stack_chk_fail_local_c} -o __stack_chk_fail_local.o
$AR r libssp_nonshared.a __stack_chk_fail_local.o"
else ""
}
'';
postInstall = '' postInstall = ''
# Not sure why, but link in all but scsi directory as that's what uclibc/glibc do. # Not sure why, but link in all but scsi directory as that's what uclibc/glibc do.
# Apparently glibc provides scsi itself? # Apparently glibc provides scsi itself?
@ -96,6 +111,13 @@ stdenv.mkDerivation rec {
$STRIP -S $out/lib/libc.a $STRIP -S $out/lib/libc.a
mkdir -p $out/bin mkdir -p $out/bin
${if (stdenv.targetPlatform.libc == "musl" && stdenv.targetPlatform.isx86_32) then
"install -D libssp_nonshared.a $out/lib/libssp_nonshared.a
$STRIP -S $out/lib/libssp_nonshared.a"
else ""
}
# Create 'ldd' symlink, builtin # Create 'ldd' symlink, builtin
ln -rs $out/lib/libc.so $out/bin/ldd ln -rs $out/lib/libc.so $out/bin/ldd

View File

@ -9881,6 +9881,9 @@ in
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
# gcc 10 is too strict to cross compile gcc <= 8
stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
isl = if stdenv.isDarwin isl = if stdenv.isDarwin
then null then null
else if stdenv.targetPlatform.isRedox else if stdenv.targetPlatform.isRedox
@ -9897,6 +9900,9 @@ in
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
# gcc 10 is too strict to cross compile gcc <= 8
stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
isl = if !stdenv.isDarwin then isl_0_17 else null; isl = if !stdenv.isDarwin then isl_0_17 else null;
})); }));
@ -9909,6 +9915,9 @@ in
libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null; libcCross = if stdenv.targetPlatform != stdenv.buildPlatform then libcCross else null;
threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null; threadsCross = if stdenv.targetPlatform != stdenv.buildPlatform then threadsCross else null;
# gcc 10 is too strict to cross compile gcc <= 8
stdenv = if (stdenv.targetPlatform != stdenv.buildPlatform) && stdenv.cc.isGNU then gcc7Stdenv else stdenv;
isl = if !stdenv.isDarwin then isl_0_17 else null; isl = if !stdenv.isDarwin then isl_0_17 else null;
})); }));