我从GNU下载了gnu-mak-3.82,并在我的Ubuntu-20.04机器上的一个特定目录(例如dir)上制作和安装它。
然后我跑了
$file dir/make它返回:
ELF 64位LSB共享对象,x86-64,version 1 (SYSV),动态链接,解释器/LSB 64/ld-Linux-x86-64.so.2,BuildIDsha1=ef2934bdbc32938713fd4cb1c9a733e8b6785af0,for GNU/Linux3.2.0,带有debug_info,没有剥离
当我跑的时候
$dir/make --version它返回:
GNU Make 3.82
Built for x86_64-unknown-linux-gnu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.当我使用最简单的Makefile运行它时,它会生成错误:
分段故障(堆芯倾弃)
为什么?我还需要做哪些额外的工作才能使它正常工作?
发布于 2022-08-27 09:01:14
根据@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. */
}然后重新制作并运行它。它可以正常工作,没有任何警告或错误。
https://stackoverflow.com/questions/73434446
复制相似问题