Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add infrastructure for testing julia's LLVM passes #21498

Merged
merged 2 commits into from
Apr 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add infrastructure for testing julia's LLVM passes
  • Loading branch information
Keno committed Apr 22, 2017
commit cae6ca798c793a1550c39eee83a8f7785a3e836c
21 changes: 21 additions & 0 deletions deps/llvm-options.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ifeq ($(LLVM_DEBUG),1)
LLVM_BUILDTYPE := Debug
else
LLVM_BUILDTYPE := Release
endif
LLVM_CMAKE_BUILDTYPE := $(LLVM_BUILDTYPE)
ifeq ($(LLVM_ASSERTIONS),1)
LLVM_BUILDTYPE := $(LLVM_BUILDTYPE)+Asserts
endif
LLVM_FLAVOR := $(LLVM_BUILDTYPE)
ifeq ($(LLVM_SANITIZE),1)
ifeq ($(SANITIZE_MEMORY),1)
LLVM_BUILDTYPE := $(LLVM_BUILDTYPE)+MSAN
else
LLVM_BUILDTYPE := $(LLVM_BUILDTYPE)+ASAN
endif
endif

LLVM_SRC_DIR:=$(SRCDIR)/srccache/llvm-$(LLVM_VER)
LLVM_BUILD_DIR:=$(BUILDDIR)/llvm-$(LLVM_VER)
LLVM_BUILDDIR_withtype := $(LLVM_BUILD_DIR)/build_$(LLVM_BUILDTYPE)
24 changes: 2 additions & 22 deletions deps/llvm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,7 @@ endif
endif
endif

ifeq ($(LLVM_DEBUG),1)
LLVM_BUILDTYPE := Debug
else
LLVM_BUILDTYPE := Release
endif
LLVM_CMAKE_BUILDTYPE := $(LLVM_BUILDTYPE)
ifeq ($(LLVM_ASSERTIONS),1)
LLVM_BUILDTYPE := $(LLVM_BUILDTYPE)+Asserts
endif
LLVM_FLAVOR := $(LLVM_BUILDTYPE)
ifeq ($(LLVM_SANITIZE),1)
ifeq ($(SANITIZE_MEMORY),1)
LLVM_BUILDTYPE := $(LLVM_BUILDTYPE)+MSAN
else
LLVM_BUILDTYPE := $(LLVM_BUILDTYPE)+ASAN
endif
endif

LLVM_SRC_DIR:=$(SRCDIR)/srccache/llvm-$(LLVM_VER)
LLVM_BUILD_DIR:=$(BUILDDIR)/llvm-$(LLVM_VER)
LLVM_BUILDDIR_withtype := $(LLVM_BUILD_DIR)/build_$(LLVM_BUILDTYPE)
include $(SRCDIR)/llvm-options.mk
LLVM_LIB_FILE := libLLVMCodeGen.a

ifeq ($(LLVM_VER), 3.3)
Expand Down Expand Up @@ -124,7 +104,7 @@ ifeq ($(USE_LLVM_SHLIB),1)
# NOTE: we could also --disable-static here (on the condition we link tools
# against libLLVM) but there doesn't seem to be a CMake counterpart option
LLVM_FLAGS += --enable-shared
LLVM_CMAKE += -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON
LLVM_CMAKE += -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON -DLLVM_LINK_LLVM_DYLIB:BOOL=ON
Copy link
Contributor

Choose a reason for hiding this comment

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

does this need to be conditional on llvm version?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like 3.8 was the first version with this option. However, I don't think CMake complains too loudly if you pass it an option it doesn't recognize.

Copy link
Sponsor Member

Choose a reason for hiding this comment

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

3.8 is the first version that we actually use CMAKE on so it should not be a problem, see #19054.

Copy link
Contributor

Choose a reason for hiding this comment

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

@Keno this flag caused #21621 - why was this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

so you can load libjulia into opt and use the llvm passes.

# NOTE: starting with LLVM 3.8, all symbols are exported
ifeq ($(LLVM_VER_SHORT),$(filter $(LLVM_VER_SHORT),3.3 3.4 3.5 3.6 3.7))
LLVM_CMAKE += -DLLVM_DYLIB_EXPORT_ALL:BOOL=ON
Expand Down
11 changes: 11 additions & 0 deletions test/llvmpasses/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
SRCDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
JULIAHOME := $(abspath $(SRCDIR)/../..)
include $(JULIAHOME)/deps/Versions.make
include $(JULIAHOME)/Make.inc
include $(JULIAHOME)/deps/llvm-ver.make
BUILDDIR = $(JULIAHOME)/deps/scratch
include $(JULIAHOME)/deps/llvm-options.mk
LLVM_SRC_DIR:=$(JULIAHOME)/deps/srccache/llvm-$(LLVM_VER)
Copy link
Sponsor Member

Choose a reason for hiding this comment

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

These configuration options aren't really right, since they assume a very specific in-tree source build layout. Does LLVM not provide any way to run its test framework out-of-tree?

Copy link
Member Author

Choose a reason for hiding this comment

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

You can build it out of tree, but you need a copy of lit which is in the LLVM source dir. You can probably make it work, but might be easier for somebody who uses out-of-tree builds to fix this up after committing this.

test:
PATH=$$PATH:$(LLVM_BUILDDIR_withtype)/bin $(LLVM_SRC_DIR)/utils/lit/lit.py -v .
.PHONY: test
15 changes: 15 additions & 0 deletions test/llvmpasses/lit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import sys
import re
import platform

import lit.util
import lit.formats

config.name = 'Julia'
config.suffixes = ['.ll']
config.test_source_root = os.path.dirname(__file__)
config.test_format = lit.formats.ShTest(False)

path = os.path.pathsep.join((os.path.join(os.path.dirname(__file__),"../../usr/tools"), config.environment['PATH']))
config.environment['PATH'] = path