Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

bootstrap.sh misconfigures linker on Mavericks #1710

Closed
jhenahan opened this Issue Mar 2, 2014 · 6 comments

Comments

Projects
None yet
3 participants
Contributor

jhenahan commented Mar 2, 2014

Using GHC 7.8-RC2: Gist

The issue is in the regex used to extract the name of the linker. In particular, when $link is interpolated in

echo 'main;' | ${CC} -v -x c - -o /dev/null -\#\#\# 2>&1 | grep ld | sed -e "s|\(.*$link\).*|\1|" -e 's/ //g' -e 's|"||'

the path gets cut off in unusual ways because it matches the text preceding the linker path up to /var/fold.

I'm not really sure of the best way to get around this. Maybe just trading out the regex for just asking for which $link.

Contributor

geoff-codes commented Mar 2, 2014

@jhenahan Can you try out this patch for me? One step apply:

curl -Ls https://gist.github.com/anonymous/f09a505ea24924e608d6/raw | git apply -v
diff --git a/cabal-install/bootstrap.sh b/cabal-install/bootstrap.sh
index a03a777..a6aded5 100755
--- a/cabal-install/bootstrap.sh
+++ b/cabal-install/bootstrap.sh
@@ -29,2 +29,6 @@ DEFAULT_PREFIX="${HOME}/.cabal"

+# Try to respect $TMPDIR but override if needed - see #1710.
+[ -"$TMPDIR"- = -""- ] || echo "$TMPDIR" | grep -q ld &&
+  export TMPDIR="$(mktemp -d /tmp/cabal-$(date +%y-%m-%d-%H-%M-%S)-X)"
+
 # Check for a C compiler.
@@ -37,3 +41,4 @@ done
 # None found.
-[ ! -x `which "$CC"` ] &&
+# `command command -v` is ugly, but `which` is non-standard (see man 1 which).
+[ ! -x "$(command command -v "$CC")" ] &&
   die "C compiler not found (or could not be run).

If not, would you mind posting the output of sh -x bootstrap.sh (-x to echo silent commands)?

Contributor

jhenahan commented Mar 2, 2014

One minor fix: you need at least three Xs in the template or mktemp chokes. Just adding another two on the end makes it work.

Now if I could just get the new Haddock to stop choking on <no location info>s I'd be golden! 😆 Thanks for the quick fix.

Contributor

geoff-codes commented Mar 2, 2014

Ugh. The issue you just pointed out - well it turns out mktemp [1] isn't standard at all.

What's your thought on:

export TMPDIR=/tmp/cabal-$(echo $(od -XN4 -An /dev/random)) && mkdir $TMPDIR

...?

Contributor

geoff-codes commented Mar 2, 2014

Now if I could just get the new Haddock to stop choking on s I'd be golden! 😆

Yeah I know. Took me ~4 hours of rebuilds to finally build pandoc.
Definitely some, um, "growing pains" here.

Should be worth it though, I think —
I'm particularly looking forward to seeing what ghcjs can do.

Contributor

jhenahan commented Mar 2, 2014

The TMPDIR version seems like it should work. Who'd have thought this'd be such a nuanced issue? Haha.

@geoff-codes geoff-codes added a commit to pullreq/cabal that referenced this issue Mar 2, 2014

@geoff-codes geoff-codes Fix for #1710. f5a44a9

@23Skidoo 23Skidoo closed this in #1711 Mar 3, 2014

@23Skidoo 23Skidoo added a commit that referenced this issue Mar 3, 2014

@23Skidoo 23Skidoo Merge pull request #1711 from pullreq/bootstrap-sh-fix
Avoid $TMPDIR / linker detection conflict in bootstrap.sh. [Fix for #1710.]
fb351fa

This fixed a symptom -- but it's still a problem. See #2542

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment