Skip to content

Instantly share code, notes, and snippets.

@killerswan
Last active March 22, 2017 00:50
Show Gist options
  • Save killerswan/51895c0ec2d8ac713d28b69e29da6b9c to your computer and use it in GitHub Desktop.
Save killerswan/51895c0ec2d8ac713d28b69e29da6b9c to your computer and use it in GitHub Desktop.
Pony's (upstream) vs. Julia's (customized) [email protected]
--- homebrew-pony/Formula/[email protected] 2017-03-21 04:31:09.000000000 -0700
+++ homebrew-julia/llvm37-julia.rb 2017-03-21 17:27:53.000000000 -0700
@@ -1,6 +1,26 @@
-class LlvmAT37 < Formula
- desc "Next-gen compiler infrastructure"
+class CodesignRequirement < Requirement
+ include FileUtils
+ fatal true
+
+ satisfy(:build_env => false) do
+ mktemp do
+ touch "llvm_check.txt"
+ quiet_system "/usr/bin/codesign", "-s", "lldb_codesign", "--dryrun", "llvm_check.txt"
+ end
+ end
+
+ def message
+ <<-EOS.undent
+ lldb_codesign identity must be available to build with LLDB.
+ See: https://llvm.org/svn/llvm-project/lldb/trunk/docs/code-signing.txt
+ EOS
+ end
+end
+
+class Llvm37Julia < Formula
+ desc "The LLVM Compiler Infrastructure"
homepage "http://llvm.org/"
+ revision 3
stable do
url "http://llvm.org/releases/3.7.1/llvm-3.7.1.src.tar.xz"
@@ -16,11 +36,26 @@
sha256 "4a91edaccad1ce984c7c49a4a87db186b7f7b21267b2b03bcf4bd7820715bc6b"
end
+ resource "compiler-rt" do
+ url "http://llvm.org/releases/3.7.1/compiler-rt-3.7.1.src.tar.xz"
+ sha256 "9d4769e4a927d3824bcb7a9c82b01e307c68588e6de4e7f04ab82d82c5af8181"
+ end
+
resource "polly" do
url "http://llvm.org/releases/3.7.1/polly-3.7.1.src.tar.xz"
sha256 "ce9273ad315e1904fd35dc64ac4375fd592f3c296252ab1d163b9ff593ec3542"
end
+ resource "lld" do
+ url "http://llvm.org/releases/3.7.1/lld-3.7.1.src.tar.xz"
+ sha256 "a929cb44b45e3181a0ad02d8c9df1d3fc71e001139455c6805f3abf2835ef3ac"
+ end
+
+ resource "lldb" do
+ url "http://llvm.org/releases/3.7.1/lldb-3.7.1.src.tar.xz"
+ sha256 "9a0bc315ef55f44c98cdf92d064df0847f453ed156dd0ef6a87e04f5fd6a0e01"
+ end
+
resource "libcxx" do
url "http://llvm.org/releases/3.7.1/libcxx-3.7.1.src.tar.xz"
sha256 "357fbd4288ce99733ba06ae2bec6f503413d258aeebaab8b6a791201e6f7f144"
@@ -34,13 +69,6 @@
end
end
- bottle do
- rebuild 1
- #sha256 "086d8f2aee762f69511d25f704579828428dafb37f308ade14cbb2cec106046e" => :sierra
- #sha256 "f61418bf5315eb0b346c23b2dbb81f9d62cdb00f173b3b5eee9e25ac96dbe796" => :el_capitan
- #sha256 "e006a9164903c96932e43c259cbd909f1316f4172a59e2057f28108e5aa87913" => :yosemite
- end
-
head do
url "http://llvm.org/git/llvm.git", :branch => "release_37"
@@ -52,10 +80,22 @@
url "http://llvm.org/git/clang-tools-extra.git", :branch => "release_37"
end
+ resource "compiler-rt" do
+ url "http://llvm.org/git/compiler-rt.git", :branch => "release_37"
+ end
+
resource "polly" do
url "http://llvm.org/git/polly.git", :branch => "release_37"
end
+ resource "lld" do
+ url "http://llvm.org/git/lld.git"
+ end
+
+ resource "lldb" do
+ url "http://llvm.org/git/lldb.git", :branch => "release_37"
+ end
+
resource "libcxx" do
url "http://llvm.org/git/libcxx.git", :branch => "release_37"
end
@@ -67,11 +107,51 @@
end
end
- patch :DATA
+ bottle do
+ root_url 'https://juliabottles.s3.amazonaws.com'
+ cellar :any
+ rebuild 1
+ sha256 "1adf4d91578a83bfd1bab56a9b27edd6fc1c4f205a75b7811deae2b02dd99a98" => :mavericks
+ sha256 "18e3bb601d7c9d3b76d52e40113c12afe1e0bd0e7664f5d7244a5013578a1773" => :yosemite
+ sha256 "6a072218991275037ddb37a1aa5f89d47b4bcf938596a2745b28f657de273638" => :el_capitan
+ sha256 "89c8f526ed2d4e33cccaa8de4290d6a95fe37c451361f8543bdc20c623ed34bf" => :sierra
+ end
+
+ keg_only 'Conflicts with llvm37 in homebrew-versions.'
+
+ def patches
+ patch_list = []
+
+ # LLVM 3.7.1 patches
+ for patch_name in ["llvm-3.7.1", "llvm-3.7.1_2", "llvm-3.7.1_3", "llvm-D14260", "llvm-nodllalias", "llvm-D21271-instcombine-tbaa-3.7"]
+ patch_list << "https://raw.githubusercontent.com/JuliaLang/julia/v0.5.0-rc2/deps/patches/#{patch_name}.patch"
+ end
+
+ # Add Homebrew's llvm37 patch
+ patch_list << "https://gist.githubusercontent.com/staticfloat/a430de88fefffcf79d1a75d7b8362aab/raw/142ac6885a438eb5555ed38f1359193ebf588b7a/homebrew-llvm37.patch"
+
+ return patch_list
+ end
+
+
+ option :universal
+ option "with-lld", "Build LLD linker"
+ option "with-lldb", "Build LLDB debugger"
+ option "with-asan", "Include support for -faddress-sanitizer (from compiler-rt)"
+ option "with-all-targets", "Build all target backends"
+ option "with-python", "Build lldb bindings against the python in PATH instead of system Python"
+ option "without-shared", "Don't build LLVM as a shared library"
+ option "with-assertions", "Slows down LLVM, but provides more debug information"
depends_on "gnu-sed" => :build
depends_on "gmp"
- depends_on "libffi"
+ depends_on "libffi" => :recommended
+ depends_on :python => :optional
+
+ if build.with? "lldb"
+ depends_on "swig"
+ depends_on CodesignRequirement
+ end
# version suffix
def ver
@@ -83,6 +163,7 @@
# Apple's libstdc++ is too old to build LLVM
fails_with :gcc
+ fails_with :llvm
def install
# One of llvm makefiles relies on gnu sed behavior to generate CMake modules correctly
@@ -98,6 +179,15 @@
libcxx_buildpath.install resource("libcxx")
(buildpath/"tools/polly").install resource("polly")
(buildpath/"tools/clang/tools/extra").install resource("clang-tools-extra")
+ (buildpath/"tools/lld").install resource("lld") if build.with? "lld"
+ (buildpath/"tools/lldb").install resource("lldb") if build.with? "lldb"
+ (buildpath/"projects/compiler-rt").install resource("compiler-rt") if build.with? "asan"
+
+ if build.universal?
+ ENV.permit_arch_flags
+ ENV["UNIVERSAL"] = "1"
+ ENV["UNIVERSAL_ARCH"] = Hardware::CPU.universal_archs.join(" ")
+ end
ENV["REQUIRES_RTTI"] = "1"
@@ -108,11 +198,18 @@
--enable-optimized
--disable-bindings
--with-gmp=#{Formula["gmp"].opt_prefix}
- --enable-shared
- --enable-targets=all
- --enable-libffi
]
+ if build.with? "all-targets"
+ args << "--enable-targets=all"
+ else
+ args << "--enable-targets=host"
+ end
+
+ args << "--enable-shared" if build.with? "shared"
+ args << "--disable-assertions" if build.without? "assertions"
+ args << "--enable-libffi" if build.with? "libffi"
+
mktemp do
system buildpath/"configure", *args
system "make", "VERBOSE=1"
@@ -177,6 +274,7 @@
(lib/"python2.7/site-packages").install "bindings/python/llvm" => "llvm-#{ver}",
clang_buildpath/"bindings/python/clang" => "clang-#{ver}"
+ (lib/"python2.7/site-packages").install_symlink install_prefix/"lib/python2.7/site-packages/lldb" => "lldb-#{ver}" if build.with? "lldb"
Dir.glob(install_prefix/"bin/*") do |exec_path|
basename = File.basename(exec_path)
@@ -208,21 +306,3 @@
end
__END__
-diff --git a/Makefile.rules b/Makefile.rules
-index ebebc0a..b0bb378 100644
---- a/Makefile.rules
-+++ b/Makefile.rules
-@@ -599,7 +599,12 @@ ifneq ($(HOST_OS), $(filter $(HOST_OS), Cygwin MingW))
- ifneq ($(HOST_OS),Darwin)
- LD.Flags += $(RPATH) -Wl,'$$ORIGIN'
- else
-- LD.Flags += -Wl,-install_name -Wl,"@rpath/lib$(LIBRARYNAME)$(SHLIBEXT)"
-+ LD.Flags += -Wl,-install_name
-+ ifdef LOADABLE_MODULE
-+ LD.Flags += -Wl,"$(PROJ_libdir)/$(LIBRARYNAME)$(SHLIBEXT)"
-+ else
-+ LD.Flags += -Wl,"$(PROJ_libdir)/$(SharedPrefix)$(LIBRARYNAME)$(SHLIBEXT)"
-+ endif
- endif
- endif
- endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment