[m-rev.] for review: Replace boehm_gc/extra/if_not_there.c with shell script.
Peter Wang
novalazy at gmail.com
Tue Aug 25 14:40:21 AEST 2015
When building Mercury natively with MinGW-w64 x86_64 under MSYS2
I saw that some process would crash in the boehm_gc directory:
./if_not_there mach_dep.o /bin/sh [snip]/../scripts/mgnuc [snip] ./mach_dep.c
^^^^Starting command^^^^
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
The same command would not crash if I ran it manually in the shell,
though it did return to the shell before completing.
Replacing if_not_there.c by a shell script avoids the problem, such that
I was able to continue and build the rest of the compiler. We require a
working shell on all platforms that we support, unlike Boehm GC upstream,
so I'm going to leave it at that.
boehm_gc/extra/if_not_there.sh:
Add shell script that mimics if_not_there.c.
boehm_gc/Makefile.direct:
Use if_not_there.sh in place of the compiled version of
if_not_there.c.
---
boehm_gc/Makefile.direct | 6 ++++--
boehm_gc/extra/if_not_there.sh | 22 ++++++++++++++++++++++
2 files changed, 26 insertions(+), 2 deletions(-)
create mode 100755 boehm_gc/extra/if_not_there.sh
diff --git a/boehm_gc/Makefile.direct b/boehm_gc/Makefile.direct
index 23c12bb..116bfa6 100644
--- a/boehm_gc/Makefile.direct
+++ b/boehm_gc/Makefile.direct
@@ -481,8 +481,10 @@ if_mach: $(srcdir)/extra/if_mach.c $(srcdir)/include/private/gcconfig.h
threadlibs: $(srcdir)/extra/threadlibs.c $(srcdir)/include/private/gcconfig.h Makefile
$(HOSTCC) $(HOSTCFLAGS) -o threadlibs $(srcdir)/extra/threadlibs.c
-if_not_there: $(srcdir)/extra/if_not_there.c
- $(HOSTCC) $(HOSTCFLAGS) -o if_not_there $(srcdir)/extra/if_not_there.c
+# Mercury-specific: use a shell script instead of if_not_there.c
+if_not_there: $(srcdir)/extra/if_not_there.sh
+ cp $< $@
+ chmod +x $@
clean:
rm -f gc.a *.o *.exe tests/*.o gctest gctest_dyn_link test_cpp \
diff --git a/boehm_gc/extra/if_not_there.sh b/boehm_gc/extra/if_not_there.sh
new file mode 100755
index 0000000..acac5f4
--- /dev/null
+++ b/boehm_gc/extra/if_not_there.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+# Conditionally execute a command based if the file doesn't exist.
+
+if test $# -lt 2
+then
+ echo "Usage: $0 file_name command" >&2
+ exit 1
+fi
+
+file=$1
+shift
+
+# The C version tests for read access, presumably because it is limited
+# to ANSI C.
+if test -e "$file"
+then
+ exit 0
+fi
+
+echo "^^^^Starting command^^^^"
+exec "$@"
+exit 1
--
2.1.2
More information about the reviews
mailing list