Open verhovsky opened 10 months ago
I disabled implicit definitions breaking the compilation by editing Makefile.in like this:
diff --git a/bash-4.3.30/Makefile.in b/bash-4.3.30/Makefile.in
index f4b59b2..0e3fee3 100644
--- a/bash-4.3.30/Makefile.in
+++ b/bash-4.3.30/Makefile.in
@@ -141,7 +141,7 @@ LIBS_FOR_BUILD =
STATIC_LD = @STATIC_LD@
LOCAL_LDFLAGS = @LOCAL_LDFLAGS@
-SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS)
+SYSTEM_FLAGS = -DPROGRAM='"$(Program)"' -DCONF_HOSTTYPE='"$(Machine)"' -DCONF_OSTYPE='"$(OS)"' -DCONF_MACHTYPE='"$(MACHTYPE)"' -DCONF_VENDOR='"$(VENDOR)"' $(LOCALE_DEFS) -Wno-implicit-function-declaration
BASE_CCFLAGS = $(PROFILE_FLAGS) $(SYSTEM_FLAGS) $(LOCAL_DEFS) \
$(DEFS) $(LOCAL_CFLAGS) $(INCLUDES) $(MAKEBASH2PY)
but then I get these errors:
rm -f siglist.o
gcc -DPROGRAM='"bash"' -DCONF_HOSTTYPE='"arm"' -DCONF_OSTYPE='"darwin23.2.0"' -DCONF_MACHTYPE='"arm-apple-darwin23.2.0"' -DCONF_VENDOR='"apple"' -DLOCALEDIR='"/usr/local/share/locale"' -DPACKAGE='"bash"' -Wno-implicit-function-declaration -DSHELL -DHAVE_CONFIG_H -DMACOSX -I. -I. -I./include -I./lib -I./lib/intl -I/Users/space/code/third-party/bash2py/bash-4.3.30/lib/intl -I/opt/homebrew/opt/node@20/include -g -O2 -c siglist.c
In file included from siglist.c:36:
In file included from ./xmalloc.h:25:
In file included from ./bashansi.h:28:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h:134:7: error: expected identifier or '('
char *strsignal(int __sig);
^
./siglist.h:37:27: note: expanded from macro 'strsignal'
# define strsignal(sig) (char *)sys_siglist[sig]
^
In file included from siglist.c:36:
In file included from ./xmalloc.h:25:
In file included from ./bashansi.h:28:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h:134:7: error: expected ')'
./siglist.h:37:27: note: expanded from macro 'strsignal'
# define strsignal(sig) (char *)sys_siglist[sig]
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/string.h:134:7: note: to match this '('
./siglist.h:37:26: note: expanded from macro 'strsignal'
# define strsignal(sig) (char *)sys_siglist[sig]
^
siglist.c:38:7: error: redefinition of 'sys_siglist' with a different type: 'char *[32]' vs 'const char *const[32]'
char *sys_siglist[NSIG];
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: previous declaration is here
extern __const char *__const sys_siglist[NSIG];
^
siglist.c:46:20: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[i] = (char *)0x0;
~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:48:18: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[0] = _("Bogus signal");
~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:51:23: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGHUP] = _("Hangup");
~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:55:23: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGINT] = _("Interrupt");
~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:59:24: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGQUIT] = _("Quit");
~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:63:23: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGILL] = _("Illegal instruction");
~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:67:24: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGTRAP] = _("BPT trace/trap");
~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:75:24: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGABRT] = _("ABORT instruction");
~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:79:23: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGEMT] = _("EMT instruction");
~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:83:23: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGFPE] = _("Floating point exception");
~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:87:24: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGKILL] = _("Killed");
~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:91:23: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGBUS] = _("Bus error");
~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:95:24: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGSEGV] = _("Segmentation fault");
~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:99:23: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGSYS] = _("Bad system call");
~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:103:24: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGPIPE] = _("Broken pipe");
~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
siglist.c:107:24: error: cannot assign to variable 'sys_siglist' with const-qualified type 'const char *const[32]'
sys_siglist[SIGALRM] = _("Alarm clock");
~~~~~~~~~~~~~~~~~~~~ ^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/signal.h:70:30: note: variable 'sys_siglist' declared const here
extern __const char *__const sys_siglist[NSIG];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [siglist.o] Error 1
Googling "error: expected identifier or '(' char *strsignal(int __sig);
" I ended up on this thread
https://www.mail-archive.com/bug-bash@gnu.org/msg25109.html
I tried to apply the change in the first patch suggested in that thread and it changed the error message in the same way
[...]
snprintf.c:1704:1: error: expected parameter declarator
vsnprintf(char *string, size_t length, const char *format, va_list args)
[...]
then I tried the changes in the combined patch
diff --git a/bash-4.3.30/aclocal.m4 b/bash-4.3.30/aclocal.m4
index a947272..5a849ed 100644
--- a/bash-4.3.30/aclocal.m4
+++ b/bash-4.3.30/aclocal.m4
@@ -300,7 +300,8 @@ AC_DEFUN(BASH_FUNC_STRSIGNAL,
[AC_MSG_CHECKING([for the existence of strsignal])
AC_CACHE_VAL(bash_cv_have_strsignal,
[AC_TRY_LINK([#include <sys/types.h>
-#include <signal.h>],
+#include <signal.h>
+#include <string.h>],
[char *s = (char *)strsignal(2);],
bash_cv_have_strsignal=yes, bash_cv_have_strsignal=no)])
AC_MSG_RESULT($bash_cv_have_strsignal)
@@ -4069,6 +4070,7 @@ AC_DEFUN([BASH_FUNC_SNPRINTF],
AC_CACHE_CHECK([for standard-conformant snprintf], [bash_cv_func_snprintf],
[AC_TRY_RUN([
#include <stdio.h>
+#include <stdlib.h>
main()
{
and ran autoconf
and it seems to work.
On my M1 Macbook Air (M1 is Apple silicon, it's the ARM64 (also called AArch64) architecture) running macOS 14.2.1 with clang 15 I get this error:
I tried compiling regular Bash 4.3 like this:
and got similar errors:
I can compile the latest Bash (commit
4b0f8ba2
) though. Bash commit8868edaf
(Bash 5.1) is the first commit I can compile on my machine. Looking at the Homebrew formula for older Bash versionshttps://github.com/Homebrew/homebrew-core/blob/9a9d87761e8ae0202440278c5835dd6805fa698c/Formula/bash.rb
it seems like there were some patches that might help here, but they 404 now (and also ARM64-based Macs didn't exist back then). They were probably these patches:
https://ftp.gnu.org/gnu/bash/bash-4.3-patches/bash43-030
The ideal way to fix this would be to rebase bash2py onto the most recent Bash version (Bash 5.2).