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
Unable to build on Alpine #743
Comments
I have successfully reproduced the build error(s), though only after fix-alpine-fortified-build.patchdiff --git a/src/cmd/ksh93/features/poll b/src/cmd/ksh93/features/poll
index 691c25482..3e4bd11e4 100644
--- a/src/cmd/ksh93/features/poll
+++ b/src/cmd/ksh93/features/poll
@@ -123,12 +123,6 @@ tst socketpair_shutdown_mode note{ fchmod() after socketpair() shutdown() }end e
}
}end
cat{
- #if _lib_poll
- # define poll _SYS_poll
- #else
- # undef _hdr_poll
- # undef _sys_poll
- #endif /* _lib_poll */
#if _hdr_poll
# include <poll.h>
#else
@@ -136,10 +130,6 @@ cat{
# include <sys/poll.h>
# endif /* _sys_poll */
#endif /* _hdr_poll */
- #if _lib_poll
- # undef poll
- extern int poll(struct pollfd*,unsigned long,int);
- #endif /* _lib_poll */
#if _lib_select
# ifndef FD_ZERO
# define FD_ZERO(x) (*(x)=0)
diff --git a/src/lib/libast/Mamfile b/src/lib/libast/Mamfile
index 0af0b6f8e..fc6228afe 100644
--- a/src/lib/libast/Mamfile
+++ b/src/lib/libast/Mamfile
@@ -2746,24 +2746,6 @@ make install virtual
exec - compile ${<}
done
- make readlink.o
- make comp/readlink.c
- prev include/error.h
- prev comp/fakelink.h implicit
- prev include/ast.h
- done
- exec - compile ${<}
- done
-
- make symlink.o
- make comp/symlink.c
- prev include/error.h
- prev comp/fakelink.h
- prev include/ast.h
- done
- exec - compile ${<}
- done
-
make getpgrp.o
make comp/getpgrp.c
prev include/ast_std.h
@@ -3103,14 +3085,6 @@ make install virtual
exec - compile ${<}
done
- make realpath.o
- make comp/realpath.c
- prev ast_map.h
- prev include/ast.h
- done
- exec - compile ${<}
- done
-
make regcmp.o
make comp/regcmp.c
prev align.h
diff --git a/src/lib/libast/comp/fakelink.h b/src/lib/libast/comp/fakelink.h
deleted file mode 100644
index aa2d70874..000000000
--- a/src/lib/libast/comp/fakelink.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/***********************************************************************
-* *
-* This software is part of the ast package *
-* Copyright (c) 1985-2011 AT&T Intellectual Property *
-* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
-* and is licensed under the *
-* Eclipse Public License, Version 2.0 *
-* *
-* A copy of the License is available at *
-* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
-* (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) *
-* *
-* Glenn Fowler <[email protected]> *
-* David Korn <[email protected]> *
-* Phong Vo <[email protected]> *
-* Martijn Dekker <[email protected]> *
-* *
-***********************************************************************/
-/*
- * AT&T Bell Laboratories
- *
- * fake symbolic link private interface
- */
-
-#ifndef _FAKELINK_H
-#define _FAKELINK_H
-
-#define FAKELINK_MAGIC "!<symlink>"
-
-#endif
diff --git a/src/lib/libast/comp/readlink.c b/src/lib/libast/comp/readlink.c
deleted file mode 100644
index eee804e8a..000000000
--- a/src/lib/libast/comp/readlink.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/***********************************************************************
-* *
-* This software is part of the ast package *
-* Copyright (c) 1985-2012 AT&T Intellectual Property *
-* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
-* and is licensed under the *
-* Eclipse Public License, Version 2.0 *
-* *
-* A copy of the License is available at *
-* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
-* (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) *
-* *
-* Glenn Fowler <[email protected]> *
-* David Korn <[email protected]> *
-* Phong Vo <[email protected]> *
-* Martijn Dekker <[email protected]> *
-* *
-***********************************************************************/
-
-#include <ast.h>
-
-#if _lib_readlink
-
-NoN(readlink)
-
-#else
-
-#include "fakelink.h"
-
-#include <error.h>
-
-int
-readlink(const char* path, char* buf, int siz)
-{
- int fd;
- int n;
-
- if (siz > sizeof(FAKELINK_MAGIC))
- {
- if ((fd = open(path, O_RDONLY|O_cloexec)) < 0)
- return -1;
- if (read(fd, buf, sizeof(FAKELINK_MAGIC)) == sizeof(FAKELINK_MAGIC) && !strcmp(buf, FAKELINK_MAGIC) && (n = read(fd, buf, siz)) > 0 && !buf[n - 1])
- {
- close(fd);
- return n;
- }
- close(fd);
- }
- errno = ENOSYS;
- return -1;
-}
-
-#endif
diff --git a/src/lib/libast/comp/realpath.c b/src/lib/libast/comp/realpath.c
deleted file mode 100644
index 2c792536b..000000000
--- a/src/lib/libast/comp/realpath.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/***********************************************************************
-* *
-* This software is part of the ast package *
-* Copyright (c) 1985-2011 AT&T Intellectual Property *
-* Copyright (c) 2020-2023 Contributors to ksh 93u+m *
-* and is licensed under the *
-* Eclipse Public License, Version 2.0 *
-* *
-* A copy of the License is available at *
-* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
-* (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) *
-* *
-* Glenn Fowler <[email protected]> *
-* David Korn <[email protected]> *
-* Phong Vo <[email protected]> *
-* Martijn Dekker <[email protected]> *
-* Johnothan King <[email protected]> *
-* *
-***********************************************************************/
-/*
- * realpath implementation
- */
-
-#define realpath ______realpath
-#define resolvepath ______resolvepath
-
-#include <ast.h>
-
-#undef realpath
-#undef resolvepath
-
-#undef _def_map_ast
-#include <ast_map.h>
-
-extern int resolvepath(const char*, char*, size_t);
-
-extern char*
-realpath(const char* file, char* path)
-{
- /* @lkoutsofios: path may be NULL */
- if (!path) {
- if (!(path = malloc (PATH_MAX)))
- return NULL;
- }
- return resolvepath(file, path, PATH_MAX) > 0 ? path : NULL;
-}
diff --git a/src/lib/libast/comp/symlink.c b/src/lib/libast/comp/symlink.c
deleted file mode 100644
index bd103e56a..000000000
--- a/src/lib/libast/comp/symlink.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/***********************************************************************
-* *
-* This software is part of the ast package *
-* Copyright (c) 1985-2012 AT&T Intellectual Property *
-* Copyright (c) 2020-2022 Contributors to ksh 93u+m *
-* and is licensed under the *
-* Eclipse Public License, Version 2.0 *
-* *
-* A copy of the License is available at *
-* https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html *
-* (with md5 checksum 84283fa8859daf213bdda5a9f8d1be1d) *
-* *
-* Glenn Fowler <[email protected]> *
-* David Korn <[email protected]> *
-* Phong Vo <[email protected]> *
-* Martijn Dekker <[email protected]> *
-* *
-***********************************************************************/
-
-#include <ast.h>
-
-#if _lib_symlink
-
-NoN(symlink)
-
-#else
-
-#include "fakelink.h"
-
-#include <error.h>
-
-int
-symlink(const char* a, char* b)
-{
- if (*a == '/' && (*(a + 1) == 'd' || *(a + 1) == 'p' || *(a + 1) == 'n') && (!strncmp(a, "/dev/tcp/", 9) || !strncmp(a, "/dev/udp/", 9) || !strncmp(a, "/proc/", 6) || !strncmp(a, "/n/", 3)))
- {
- int n;
- int fd;
-
- if ((fd = open(b, O_CREAT|O_TRUNC|O_WRONLY|O_cloexec, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)) < 0)
- return -1;
- n = strlen(a) + 1;
- n = (write(fd, FAKELINK_MAGIC, sizeof(FAKELINK_MAGIC)) != sizeof(FAKELINK_MAGIC) || write(fd, a, n) != n) ? -1 : 0;
- close(fd);
- return n;
- }
- errno = ENOSYS;
- return -1;
-}
-
-#endif
diff --git a/src/lib/libast/features/map.c b/src/lib/libast/features/map.c
index 627e05a47..6d743cc90 100644
--- a/src/lib/libast/features/map.c
+++ b/src/lib/libast/features/map.c
@@ -231,9 +231,6 @@ main(void)
printf("#define re_comp _ast_re_comp\n");
printf("#undef re_exec\n");
printf("#define re_exec _ast_re_exec\n");
- printf("#undef realpath\n");
- printf("#define realpath _ast_realpath\n");
- printf("extern char* realpath(const char*, char*);\n");
#endif
/* Override the native regex library in favor of libast's regex functions */
printf("#undef regaddclass\n");
diff --git a/src/lib/libast/string/strlcat.c b/src/lib/libast/string/strlcat.c
index 0ccee0394..a4918fd26 100644
--- a/src/lib/libast/string/strlcat.c
+++ b/src/lib/libast/string/strlcat.c
@@ -20,12 +20,8 @@
* strlcat implementation
*/
-#define strlcat ______strlcat
-
#include <ast.h>
-#undef strlcat
-
#undef _def_map_ast
#include <ast_map.h>
diff --git a/src/lib/libast/string/strlcpy.c b/src/lib/libast/string/strlcpy.c
index 20428aafc..2cbb69af7 100644
--- a/src/lib/libast/string/strlcpy.c
+++ b/src/lib/libast/string/strlcpy.c
@@ -20,12 +20,8 @@
* strlcpy implementation
*/
-#define strlcpy ______strlcpy
-
#include <ast.h>
-#undef strlcpy
-
#undef _def_map_ast
#include <ast_map.h>
diff --git a/src/lib/libcmd/uname.c b/src/lib/libcmd/uname.c
index a64917f43..6b7b8194d 100644
--- a/src/lib/libcmd/uname.c
+++ b/src/lib/libcmd/uname.c
@@ -66,11 +66,6 @@ static const char usage[] =
" \bsysconf\b(3), \bsysinfo\b(2)]"
;
-#define getdomainname ______getdomainname
-#define gethostid ______gethostid
-#define gethostname ______gethostname
-#define sethostname ______sethostname
-
#include <cmd.h>
#include <ctype.h>
#include <stdio.h>
@@ -84,24 +79,6 @@ static const char usage[] =
# include <sys/utsname.h>
#endif
-#undef getdomainname
-#undef gethostid
-#undef gethostname
-#undef sethostname
-
-#if _lib_getdomainname
-extern int getdomainname(char*, size_t);
-#endif
-#if _lib_gethostid
-extern long gethostid(void);
-#endif
-#if _lib_gethostname
-extern int gethostname(char*, size_t);
-#endif
-#if _lib_sethostname
-extern int sethostname(const char*, size_t);
-#endif
-
#ifndef HOSTTYPE
#define HOSTTYPE "unknown"
#endif
|
@JohnoKing thanks for prompt reply and quick patch! I dug a little deeper, and it turns out that both I was able to compile and run tests, however I also had to extend your patch with this: diff --git a/src/lib/libast/misc/univlib.h b/src/lib/libast/misc/univlib.h
index 324322c9..a0c62581 100644
--- a/src/lib/libast/misc/univlib.h
+++ b/src/lib/libast/misc/univlib.h
@@ -33,9 +33,7 @@
#define _UNIVLIB_H
#define getuniverse ______getuniverse
-#define readlink ______readlink
#define setuniverse ______setuniverse
-#define symlink ______symlink
#define universe ______universe
#include <ast.h>
@@ -49,9 +47,7 @@
#endif
#undef getuniverse
-#undef readlink
#undef setuniverse
-#undef symlink
#undef universe
#if _cmd_universe
@@ -73,9 +69,7 @@ extern char univ_env[];
#endif
extern int getuniverse(char*);
-extern int readlink(const char*, char*, int);
extern int setuniverse(int);
-extern int symlink(const char*, const char*);
extern int universe(int);
#endif
test run
|
This commit removes obsolete compatibility code that was causing compilation errors on Alpine Linux when the fortify-headers package is installed. In short, the readlink, symlink and realpath compatibility functions in src/lib/libast/comp don't work with Alpine Linux's fortified headers. None of these functions are necessary to compile on current operating systems (tested on Linux with glibc and musl, {Free,Net,Open,DragonFly}BSD, illumos, Haiku and Cygwin) so these can be safely deleted. Additionally, some spurious macro hackery relating to strlcpy, strlcat and networking functions used in libcmd uname has also been deleted. (The patch to univlib.h is taken from ksh93#743 (comment).) Co-authored-by: xorrvin <[email protected]>
This commit removes obsolete compatibility code that was causing compilation errors on Alpine Linux when the fortify-headers package is installed. In short, the readlink, symlink and realpath compatibility functions in src/lib/libast/comp don't work with Alpine Linux's fortified headers. None of these functions are necessary to compile on current operating systems (tested on Linux with glibc and musl, {Free,Net,Open,DragonFly}BSD, illumos, Haiku and Cygwin) so these can be safely deleted. Additionally, some spurious macro hackery relating to strlcpy, strlcat and networking functions used in libcmd uname has also been deleted. (The patch to univlib.h is taken from ksh93#743 (comment).) Co-authored-by: xorrvin <[email protected]>
Hi, probably known issue, but for some reason I cannot build both
1.0.8
and latest master (2e8aeee968a4d58fda0d95b2aba6b629e9cd46b1
) on Alpine Linux (musl libc).The error I'm having is this (compiling with GCC):
or this (compiling with Clang)
How to reproduce:
Now to the interesting part: ksh is packaged for Gentoo and there's no issue there. I've test it on glibc and musl 1.23 and 1.24 with both gcc and clang, on amd64 and arm64, each of them is able to build latest master commit. Gentoo does patch musl (https://gitweb.gentoo.org/repo/gentoo.git/tree/sys-libs/musl/musl-1.2.4-r1.ebuild), but it looks like these patches are not relevant.
The text was updated successfully, but these errors were encountered: