Skip to content

Commit

Permalink
Commit ugly llvm python workaround to make it compile on Arch
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed May 28, 2012
1 parent 9bf6369 commit 504b953
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions deps/Makefile
Expand Up @@ -142,11 +142,22 @@ llvm-$(LLVM_VER)/configure: $(LLVM_TAR)
tar -C llvm-$(LLVM_VER) --strip-components 1 -xf $<
touch $@

$(LLVM_OBJ_SOURCE): llvm-$(LLVM_VER)/configure
## LLVM needs python 2.x, but doesn't check for it, so we have to use an ugly workaround to make it compile
llvm_python_workaround:
-python -c 'import sys; sys.exit(not sys.version_info > (3, 0))' && \
/usr/bin/python2 -c 'import sys; sys.exit(not sys.version_info < (3, 0))' && \
export PATH=$(abspath llvm-$(LLVM_VER)/python2_path):$$PATH && \
test ! -e llvm-$(LLVM_VER)/python2_path/python && \
mkdir -p llvm-$(LLVM_VER)/python2_path && \
ln -s /usr/bin/python2 "llvm-$(LLVM_VER)/python2_path/python"

$(LLVM_OBJ_SOURCE): llvm-$(LLVM_VER)/configure llvm_python_workaround
cd llvm-$(LLVM_VER) && \
export PATH=$(abspath llvm-$(LLVM_VER)/python2_path):$$PATH && \
./configure --prefix=$(abspath $(USR)) --disable-threads --enable-optimized --disable-profiling --disable-assertions --enable-shared --enable-targets=x86,x86_64 --disable-bindings --disable-docs CC=$(GCC) CXX=$(GPLUSPLUS) && \
$(MAKE)
$(LLVM_OBJ_TARGET): $(LLVM_OBJ_SOURCE)
$(LLVM_OBJ_TARGET): $(LLVM_OBJ_SOURCE) llvm_python_workaround
export PATH=$(abspath llvm-$(LLVM_VER)/python2_path):$$PATH && \
$(MAKE) -C llvm-$(LLVM_VER) install
$(INSTALL_NAME_CMD) libLLVM-$(LLVM_VER).$(SHLIB_EXT) $(USRLIB)/libLLVM-$(LLVM_VER).$(SHLIB_EXT)
touch $@
Expand Down

6 comments on commit 504b953

@JeffBezanson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This causes llvm to be rebuilt on every make! Probably because llvm_python_workaround is unconditional.

@Keno
Copy link
Member Author

@Keno Keno commented on 504b953 May 28, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that. Should be fixed by 623bc39

@JeffBezanson
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a patch that fixed it for me:

diff --git a/deps/Makefile b/deps/Makefile
index d57b1cc..b091761 100644
--- a/deps/Makefile
+++ b/deps/Makefile
@@ -142,21 +142,24 @@ llvm-$(LLVM_VER)/configure: $(LLVM_TAR)
        tar -C llvm-$(LLVM_VER) --strip-components 1 -xf $<
        touch $@

+LLVM_PYTHON_WORKAROUND=llvm-$(LLVM_VER)/python2_path/python
+
 ## LLVM needs python 2.x, but doesn't check for it, so we have to use an ugly workaround to make it compile
-llvm_python_workaround:
-       -python -c 'import sys; sys.exit(not sys.version_info > (3, 0))' && \
+$(LLVM_PYTHON_WORKAROUND):
+       (python -c 'import sys; sys.exit(not sys.version_info > (3, 0))' && \
        /usr/bin/python2 -c 'import sys; sys.exit(not sys.version_info < (3, 0))' && \
        export PATH=$(abspath llvm-$(LLVM_VER)/python2_path):$$PATH && \
        test ! -e llvm-$(LLVM_VER)/python2_path/python && \
        mkdir -p llvm-$(LLVM_VER)/python2_path && \
-       ln -s /usr/bin/python2 "llvm-$(LLVM_VER)/python2_path/python"
+       ln -sf /usr/bin/python2 "llvm-$(LLVM_VER)/python2_path/python") || \
+       ln -sf `which python` "llvm-$(LLVM_VER)/python2_path/python"

-$(LLVM_OBJ_SOURCE): llvm-$(LLVM_VER)/configure llvm_python_workaround
+$(LLVM_OBJ_SOURCE): llvm-$(LLVM_VER)/configure $(LLVM_PYTHON_WORKAROUND)
        cd llvm-$(LLVM_VER) && \
        export PATH=$(abspath llvm-$(LLVM_VER)/python2_path):$$PATH && \
        ./configure --prefix=$(abspath $(USR)) --disable-threads --enable-optimized --disable-profiling --disable-assertions --enable-shared --enable-targets=x86,x86_64 --disable-bindings --disable-docs CC=$(GCC) CXX=$(GPLUSPLUS) && \
        $(MAKE)
-$(LLVM_OBJ_TARGET): $(LLVM_OBJ_SOURCE) llvm_python_workaround
+$(LLVM_OBJ_TARGET): $(LLVM_OBJ_SOURCE) $(LLVM_PYTHON_WORKAROUND)
        export PATH=$(abspath llvm-$(LLVM_VER)/python2_path):$$PATH && \
        $(MAKE) -C llvm-$(LLVM_VER) install
        $(INSTALL_NAME_CMD) libLLVM-$(LLVM_VER).$(SHLIB_EXT) $(USRLIB)/libLLVM-$(LLVM_VER).$(SHLIB_EXT)

@Keno
Copy link
Member Author

@Keno Keno commented on 504b953 May 28, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already fixed by using order-only prerequisites.

@ViralBShah
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this breaks on Mac.


python -c 'import sys; sys.exit(not sys.version_info > (3, 0))' && \
    /usr/bin/python2 -c 'import sys; sys.exit(not sys.version_info < (3, 0))' && \
    export PATH=/Users/viral/julia/deps/llvm-3.1/python2_path:$PATH && \
    test ! -e llvm-3.1/python2_path/python && \
    mkdir -p llvm-3.1/python2_path && \
    ln -s /usr/bin/python2 "llvm-3.1/python2_path/python"
make: [llvm_python_workaround] Error 1 (ignored)

@Keno
Copy link
Member Author

@Keno Keno commented on 504b953 May 29, 2012

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's intended since there's no need for this workaround on mac. Thus the (ignored)

Please sign in to comment.