[LLVMdev] Dealing with a corrupted /proc/self/exe link

Gabor Greif gabor.greif at alcatel-lucent.com
Fri Jul 13 00:46:55 PDT 2012


Hi all,

I am in charge of the controlled introduction of clang into
our builds at my workplace. Since all our tools must run from
a ClearCase view for automatic dependency tracking, we have been
biten by a Linux bug, and readlink("/proc/self/exe", ...) gives
nonsensical results. So we need to introduce a configure option
for disallowing this method of executable discovery (the other
one works well).

Here is the patch:



Index: autoconf/configure.ac
===================================================================
--- autoconf/configure.ac       (revision 160127)
+++ autoconf/configure.ac       (working copy)
@@ -647,6 +647,20 @@
 AC_DEFINE_UNQUOTED([ENABLE_TIMESTAMPS],$ENABLE_TIMESTAMPS,
                    [Define if timestamp information (e.g., __DATE__) is allowed])

+dnl Enable reading of the "/proc/self/exe" link.
+AC_ARG_ENABLE(proc-self-exe,
+  AS_HELP_STRING([--enable-proc-self-exe],
+                 [Enable reading of the "/proc/self/exe" link (default is YES)]),,
+                 enableval=default)
+case "$enableval" in
+  yes) AC_SUBST(ENABLE_PROC_SELF_EXE,[1]) ;;
+  no)  AC_SUBST(ENABLE_PROC_SELF_EXE,[0]) ;;
+  default) AC_SUBST(ENABLE_PROC_SELF_EXE,[1]) ;;
+  *) AC_MSG_ERROR([Invalid setting for --enable-proc-self-exe. Use "yes" or "no"]) ;;
+esac
+AC_DEFINE_UNQUOTED([ENABLE_PROC_SELF_EXE],$ENABLE_PROC_SELF_EXE,
+                   [Define if reading of the "/proc/self/exe" link is allowed])
+
 dnl Allow specific targets to be specified for building (or not)
 TARGETS_TO_BUILD=""
 AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],


I'll commit after a LGTM.

However before tweaking lib/Support/Unix/Path.inc I have to add a cmake
modification, which can be simply <always on>. Hints how to do this are
welcome, but I guess I'll figure it out.

So what do you think?

Cheers,

	Gabor



More information about the llvm-dev mailing list