gnu-make 3.82 在 Ubuntu-20.04 上运行错误:分段错误(核心转储)

gnu-make 3.82 在 Ubuntu-20.04 上运行错误:分段错误(核心转储)

我从 gun 下载了 gnu-make-3.82,并在我的 Ubuntu-20.04 机器上的特定目录(egdir)上制作和安装它。

然后我跑

$file dir/make

它返回:

ELF 64 位 LSB 共享对象,x86-64,版本 1 (SYSV),动态链接,解释器 /lib64/ld-linux-x86-64.so.2,BuildID[sha1]=ef2934bdbc32938713fd4cb1c9a733e8b6785af0,适用于 GNU/Linux 3.2.0,带有 debug_info,未被剥离

当我跑步时

$dir/make --version

它返回:

GNU Make 3.82 专为 x86_64-unknown-linux-gnu 构建 版权所有 (C) 2010 Free Software Foundation, Inc. 许可证 GPLv3+:GNU GPL 版本 3 或更高版本http://gnu.org/licenses/gpl.html这是免费软件:您可以自由更改和重新分发它。在法律允许的范围内,不提供任何保证。

当我使用最简单的 Makefile 运行它时,它会产生错误:

分段错误(核心转储)

为什么?我还需要做哪些额外的工作才能使其正常工作?

答案1

根据@steeldriver的提示,我对dir.c做了如下修改。

diff --git a/dir.c b/dir.c
index adbb8a9..c343e4c 100644
--- a/dir.c
+++ b/dir.c
@@ -1299,15 +1299,40 @@ local_stat (const char *path, struct stat *buf)
 }
 #endif
 
+/* Similarly for lstat.  */
+#if !defined(lstat) && !defined(WINDOWS32) || defined(VMS)
+# ifndef VMS
+#  ifndef HAVE_SYS_STAT_H
+int lstat (const char *path, struct stat *sbuf);
+#  endif
+# else
+    /* We are done with the fake lstat.  Go back to the real lstat */
+#   ifdef lstat
+#     undef lstat
+#   endif
+# endif
+# define local_lstat lstat
+#elif defined(WINDOWS32)
+/* Windows doesn't support lstat().  */
+# define local_lstat local_stat
+#else
+static int
+local_lstat (const char *path, struct stat *buf)
+{
+  int e;
+  EINTRLOOP (e, lstat (path, buf));
+  return e;
+}
+#endif
+
 void
 dir_setup_glob (glob_t *gl)
 {
   gl->gl_opendir = open_dirstream;
   gl->gl_readdir = read_dirstream;
   gl->gl_closedir = free;
+  gl->gl_lstat = local_lstat;
   gl->gl_stat = local_stat;
-  /* We don't bother setting gl_lstat, since glob never calls it.
-     The slot is only there for compatibility with 4.4 BSD.  */
 }

然后重新制作并运行它。它运行正常,没有任何警告或错误。

相关内容