-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
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
WIP: improve support for crosscompiling to musl32 #62817
Closed
Closed
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
db5d5e2
disable stackprotector on target platform musl32
wfranzini ee2ad96
libexecinfo: enables stackprotector through hardeningEnable
wfranzini 533dcc7
libsodium: disable stackprotector on musl32
wfranzini 3a163f9
audit: backport from upstream support for system w/o strndupa/rawmemchr
wfranzini 63762fc
bison2: add perl in nativeBuildInputs
wfranzini b509a5f
sox: musl does not support pipe rewind
wfranzini c6ecd1a
identify musl32 using x86_32 instead of i686
wfranzini 8b7219b
add stackprotector support on musl32
wfranzini File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
pkgs/applications/misc/audio/sox/0001-musl-rewind-pipe-workaround.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
From e7446c9bcb47674c9d0ee3b5bab129e9b86eb1c9 Mon Sep 17 00:00:00 2001 | ||
From: Walter Franzini <[email protected]> | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
pkgs/development/libraries/libexecinfo/30-linux-makefile.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <[email protected]>, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
pkgs/os-specific/linux/audit/audit-strndupa-rawmemchr-compat.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,141 @@ | ||||||
From d579a08bb1cde71f939c13ac6b2261052ae9f77e Mon Sep 17 00:00:00 2001 | ||||||
From: Steve Grubb <[email protected]> | ||||||
Date: Tue, 26 Feb 2019 18:33:33 -0500 | ||||||
Subject: [PATCH] Add substitue functions for strndupa & rawmemchr | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
--- | ||||||
ChangeLog | 1 + | ||||||
auparse/auparse.c | 12 +++++++++++- | ||||||
auparse/interpret.c | 11 +++++++++-- | ||||||
configure.ac | 14 +++++++++++++- | ||||||
src/ausearch-lol.c | 12 +++++++++++- | ||||||
5 files changed, 45 insertions(+), 5 deletions(-) | ||||||
|
||||||
diff --git a/ChangeLog b/ChangeLog | ||||||
index 253c63b..14ee2d0 100644 | ||||||
--- a/ChangeLog | ||||||
+++ b/ChangeLog | ||||||
@@ -62,6 +62,7 @@ | ||||||
- Allow exclude and user filter by executable name (Ondrej Mosnacek) | ||||||
- Fix auditd regression where keep_logs is limited by rotate_logs 2 file test | ||||||
- In ausearch/report fix --end to use midnight time instead of now (#1671338) | ||||||
+- Add substitue functions for strndupa & rawmemchr | ||||||
|
||||||
2.8.3 | ||||||
- Correct msg function name in LRU debug code | ||||||
diff --git a/auparse/auparse.c b/auparse/auparse.c | ||||||
index 69127b7..042ea2b 100644 | ||||||
--- a/auparse/auparse.c | ||||||
+++ b/auparse/auparse.c | ||||||
@@ -1,5 +1,5 @@ | ||||||
/* auparse.c -- | ||||||
- * Copyright 2006-08,2012-17 Red Hat Inc., Durham, North Carolina. | ||||||
+ * Copyright 2006-08,2012-19 Red Hat Inc., Durham, North Carolina. | ||||||
* All Rights Reserved. | ||||||
* | ||||||
* This library is free software; you can redistribute it and/or | ||||||
@@ -1119,6 +1119,16 @@ static int str2event(char *s, au_event_t *e) | ||||||
return 0; | ||||||
} | ||||||
|
||||||
+#ifndef HAVE_STRNDUPA | ||||||
+static inline char *strndupa(const char *old, size_t n) | ||||||
+{ | ||||||
+ size_t len = strnlen(old, n); | ||||||
+ char *tmp = alloca(len + 1); | ||||||
+ tmp[len] = 0; | ||||||
+ return memcpy(tmp, old, len); | ||||||
+} | ||||||
+#endif | ||||||
+ | ||||||
/* Returns 0 on success and 1 on error */ | ||||||
static int extract_timestamp(const char *b, au_event_t *e) | ||||||
{ | ||||||
diff --git a/auparse/interpret.c b/auparse/interpret.c | ||||||
index 88523c6..f19ee85 100644 | ||||||
--- a/auparse/interpret.c | ||||||
+++ b/auparse/interpret.c | ||||||
@@ -855,6 +855,13 @@ static const char *print_escaped_ext(const idata *id) | ||||||
return print_escaped(id->val); | ||||||
} | ||||||
|
||||||
+// rawmemchr is faster. Let's use it if we have it. | ||||||
+#ifdef HAVE_RAWMEMCHR | ||||||
+#define STRCHR rawmemchr | ||||||
+#else | ||||||
+#define STRCHR strchr | ||||||
+#endif | ||||||
+ | ||||||
static const char *print_proctitle(const char *val) | ||||||
{ | ||||||
char *out = (char *)print_escaped(val); | ||||||
@@ -865,7 +872,7 @@ static const char *print_proctitle(const char *val) | ||||||
// Proctitle has arguments separated by NUL bytes | ||||||
// We need to write over the NUL bytes with a space | ||||||
// so that we can see the arguments | ||||||
- while ((ptr = rawmemchr(ptr, '\0'))) { | ||||||
+ while ((ptr = STRCHR(ptr, '\0'))) { | ||||||
if (ptr >= end) | ||||||
break; | ||||||
*ptr = ' '; | ||||||
diff --git a/configure.ac b/configure.ac | ||||||
index acd6d61..00658d4 100644 | ||||||
--- a/configure.ac | ||||||
+++ b/configure.ac | ||||||
@@ -1,7 +1,7 @@ | ||||||
dnl | ||||||
define([AC_INIT_NOTICE], | ||||||
[### Generated automatically using autoconf version] AC_ACVERSION [ | ||||||
-### Copyright 2005-18 Steve Grubb <[email protected]> | ||||||
+### Copyright 2005-19 Steve Grubb <[email protected]> | ||||||
### | ||||||
### Permission is hereby granted, free of charge, to any person obtaining a | ||||||
### copy of this software and associated documentation files (the "Software"), | ||||||
@@ -72,6 +72,18 @@ dnl; posix_fallocate is used in audisp-remote | ||||||
AC_CHECK_FUNCS([posix_fallocate]) | ||||||
dnl; signalfd is needed for libev | ||||||
AC_CHECK_FUNC([signalfd], [], [ AC_MSG_ERROR([The signalfd system call is necessary for auditd]) ]) | ||||||
+dnl; check if rawmemchr is available | ||||||
+AC_CHECK_FUNCS([rawmemchr]) | ||||||
+dnl; check if strndupa is available | ||||||
+AC_LINK_IFELSE( | ||||||
+ [AC_LANG_SOURCE( | ||||||
+ [[ | ||||||
+ #define _GNU_SOURCE | ||||||
+ #include <string.h> | ||||||
+ int main() { (void) strndupa("test", 10); return 0; }]])], | ||||||
+ [AC_DEFINE(HAVE_STRNDUPA, 1, [Let us know if we have it or not])], | ||||||
+ [] | ||||||
+) | ||||||
|
||||||
ALLWARNS="" | ||||||
ALLDEBUG="-g" | ||||||
diff --git a/src/ausearch-lol.c b/src/ausearch-lol.c | ||||||
index bebbcf4..0babd51 100644 | ||||||
--- a/src/ausearch-lol.c | ||||||
+++ b/src/ausearch-lol.c | ||||||
@@ -1,6 +1,6 @@ | ||||||
/* | ||||||
* ausearch-lol.c - linked list of linked lists library | ||||||
-* Copyright (c) 2008,2010,2014,2016 Red Hat Inc., Durham, North Carolina. | ||||||
+* Copyright (c) 2008,2010,2014,2016,2019 Red Hat Inc., Durham, North Carolina. | ||||||
* All Rights Reserved. | ||||||
* | ||||||
* This software may be freely redistributed and/or modified under the | ||||||
@@ -152,6 +152,16 @@ static int compare_event_time(event *e1, event *e2) | ||||||
return 0; | ||||||
} | ||||||
|
||||||
+#ifndef HAVE_STRNDUPA | ||||||
+static inline char *strndupa(const char *old, size_t n) | ||||||
+{ | ||||||
+ size_t len = strnlen(old, n); | ||||||
+ char *tmp = alloca(len + 1); | ||||||
+ tmp[len] = 0; | ||||||
+ return memcpy(tmp, old, len); | ||||||
+} | ||||||
+#endif | ||||||
+ | ||||||
/* | ||||||
* This function will look at the line and pick out pieces of it. | ||||||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if alpine has a way to get ssp working?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@matthewbauer Alpinelinux creates a small libssp_nonshared library in the musl-dev package.
https://git.alpinelinux.org/aports/tree/main/musl?h=master
I've recreated it in my local nixpkgs repo, however I'm not sure how to automatically link with libssp_nonshared.a.
Do you have a hint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably need to put it in musl's $out/lib/libssp_nonshared.a. Unfortunately we also need to apply this patch to GCC:
https://git.alpinelinux.org/aports/tree/main/gcc/gcc-6.1-musl-libssp.patch
That would probably be okay to apply to GCC, but maybe only on i686-musl builds.