Skip to content

Instantly share code, notes, and snippets.

@killerswan
Created March 22, 2017 00:50
Show Gist options
  • Save killerswan/cc9e8e839c898f15905701ab1feabbb8 to your computer and use it in GitHub Desktop.
Save killerswan/cc9e8e839c898f15905701ab1feabbb8 to your computer and use it in GitHub Desktop.
Pony's (upstream) vs. Julia's (customized) LLVM@3.9
--- homebrew-pony/Formula/llvm@3.9.rb 2017-03-21 04:31:09.000000000 -0700
+++ homebrew-julia/llvm39-julia.rb 2017-03-21 17:27:53.000000000 -0700
@@ -17,7 +17,7 @@
end
end
-class LlvmAT39 < Formula
+class Llvm39Julia < Formula
desc "Next-gen compiler infrastructure"
homepage "http://llvm.org/"
@@ -72,56 +72,68 @@
sha256 "9ba5e61fc7bf8c7435f64e2629e0810c9b1d1b03aa5b5605b780d0e177b4cb46"
end
end
- bottle do
- cellar :any
- #sha256 "367c8263a2ddb03b01026144cbacbb59a5c89678f0cd6b66a8ca7e54e3a6f09a" => :sierra
- #sha256 "a71eccd058680a69428d42f0f936879c5fd051664acb2ef614c257116dd3d9e4" => :el_capitan
- #sha256 "3eb7fd1ce32ce5489c85c209d709b07aed6d720f316cdbe12faca0019ba3b1a7" => :yosemite
- end
-
head do
- url "http://llvm.org/git/llvm.git", :branch => "release_39"
+ url "http://llvm.org/git/llvm.git"
resource "clang" do
- url "http://llvm.org/git/clang.git", :branch => "release_39"
+ url "http://llvm.org/git/clang.git"
end
resource "clang-extra-tools" do
- url "http://llvm.org/git/clang-tools-extra.git", :branch => "release_39"
+ url "http://llvm.org/git/clang-tools-extra.git"
end
resource "compiler-rt" do
- url "http://llvm.org/git/compiler-rt.git", :branch => "release_39"
+ url "http://llvm.org/git/compiler-rt.git"
end
resource "libcxx" do
- url "http://llvm.org/git/libcxx.git", :branch => "release_39"
+ url "http://llvm.org/git/libcxx.git"
end
resource "libunwind" do
- url "http://llvm.org/git/libunwind.git", :branch => "release_39"
+ url "http://llvm.org/git/libunwind.git"
end
resource "lld" do
- url "http://llvm.org/git/lld.git", :branch => "release_39"
+ url "http://llvm.org/git/lld.git"
end
resource "lldb" do
- url "http://llvm.org/git/lldb.git", :branch => "release_39"
+ url "http://llvm.org/git/lldb.git"
end
resource "openmp" do
- url "http://llvm.org/git/openmp.git", :branch => "release_39"
+ url "http://llvm.org/git/openmp.git"
end
resource "polly" do
- url "http://llvm.org/git/polly.git", :branch => "release_39"
+ url "http://llvm.org/git/polly.git"
end
end
- keg_only :versioned_formula
+ bottle do
+ root_url 'https://juliabottles.s3.amazonaws.com'
+ cellar :any
+ sha256 "7ed132633a51174f5ff2b6e9df4710ba199634fe95ccea0aeebfe330cd51bcde" => :mavericks
+ sha256 "b559e788557d816c75bea8a8f01f1636e418a71385ea6956933b9805fd755422" => :yosemite
+ sha256 "f7fe9e8c1fdfb20510e38c34c3d3ad2c70e6bf3f95448b86fa91d3eebc31d78b" => :el_capitan
+ sha256 "5b7787e5659cbe20e3f09d264455a1b8cdd60cb935641399fb117998e0b3352f" => :sierra
+ end
+
+ def patches
+ patch_list = []
+ for patch_name in ["PR22923", "arm-fix-prel31", "D25865-cmakeshlib", "3.9.0_win64-reloc-dwarf", "3.9.0_D27296-libssp", "D27609-AArch64-UABS_G3", "D27629-AArch64-large_model", "D9168_argument_alignment", "D23597_sdag_names", "D24300_ptx_intrinsics"]
+ patch_list << "https://raw.githubusercontent.com/JuliaLang/julia/51b6b06fb42b19d4204358ef0b216da2bf561502/deps/patches/llvm-#{patch_name}.patch"
+ end
+ return patch_list
+ end
+
+ keg_only :provided_by_osx
+
+ option :universal
option "without-compiler-rt", "Do not build Clang runtime support libraries for code sanitizers, builtins, and profiling"
option "without-libcxx", "Do not build libc++ standard library"
option "with-toolchain", "Build with Toolchain to facilitate overriding system compiler"
@@ -129,6 +141,7 @@
option "with-python", "Build bindings against custom Python"
option "with-shared-libs", "Build shared instead of static libraries"
option "without-libffi", "Do not use libffi to call external functions"
+ option "with-all-targets", "Build all targets. Default targets: AMDGPU, ARM, NVPTX, and X86"
depends_on "libffi" => :recommended # http://llvm.org/docs/GettingStarted.html#requirement
depends_on "graphviz" => :optional # for the 'dot' tool (lldb)
@@ -213,8 +226,8 @@
-DLLVM_INSTALL_UTILS=ON
-DWITH_POLLY=ON
-DLINK_POLLY_INTO_TOOLS=ON
- -DLLVM_TARGETS_TO_BUILD=all
]
+ args << "-DLLVM_TARGETS_TO_BUILD=#{build.with?("all-targets") ? "all" : "AMDGPU;ARM;NVPTX;X86"}"
args << "-DLIBOMP_ARCH=x86_64"
args << "-DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON" if build.with? "compiler-rt"
args << "-DLLVM_CREATE_XCODE_TOOLCHAIN=ON" if build.with? "toolchain"
@@ -240,6 +253,11 @@
args << "-DFFI_LIBRARY_DIR=#{Formula["libffi"].opt_lib}"
end
+ if build.universal?
+ ENV.permit_arch_flags
+ args << "-DCMAKE_OSX_ARCHITECTURES=#{Hardware::CPU.universal_archs.as_cmake_arch_flags}"
+ end
+
mktemp do
if build.with? "ocaml"
ENV["OPAMYES"] = "1"
@@ -300,8 +318,8 @@
}
EOS
- system "#{bin}/clang", "-L#{lib}", "-Wl,-rpath,#{lib}", "-fopenmp",
- "-nobuiltininc", "-I#{lib}/clang/#{version}/include",
+ system "#{bin}/clang", "-L#{lib}", "-fopenmp", "-nobuiltininc",
+ "-I#{lib}/clang/#{version}/include",
"omptest.c", "-o", "omptest"
testresult = shell_output("./omptest")
@@ -343,7 +361,7 @@
"-I#{libclangclt}/include",
"-I/usr/include", # need it because /Library/.../usr/include/c++/v1/iosfwd refers to <wchar.h>, which CLT installs to /usr/include
"test.cpp", "-o", "testCLT++"
- assert_includes MachO::Tools.dylibs("testCLT++"), "/usr/lib/libc++.1.dylib"
+ assert_match "/usr/lib/libc++.1.dylib", shell_output("otool -L ./testCLT++").chomp
assert_equal "Hello World!", shell_output("./testCLT++").chomp
system "#{bin}/clang", "-v", "-nostdinc",
@@ -361,7 +379,7 @@
"-I#{libclangxc}/include",
"-I#{MacOS.sdk_path}/usr/include",
"test.cpp", "-o", "testXC++"
- assert_includes MachO::Tools.dylibs("testXC++"), "/usr/lib/libc++.1.dylib"
+ assert_match "/usr/lib/libc++.1.dylib", shell_output("otool -L ./testXC++").chomp
assert_equal "Hello World!", shell_output("./testXC++").chomp
system "#{bin}/clang", "-v", "-nostdinc",
@@ -380,7 +398,7 @@
"-I#{MacOS.sdk_path}/usr/include",
"-L#{lib}",
"-Wl,-rpath,#{lib}", "test.cpp", "-o", "test"
- assert_includes MachO::Tools.dylibs("test"), "@rpath/libc++.1.dylib"
+ assert_match "#{opt_lib}/libc++.1.dylib", shell_output("otool -L ./test").chomp
assert_equal "Hello World!", shell_output("./test").chomp
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment