Skip to content

Commit

Permalink
emscripten: rebuild
Browse files Browse the repository at this point in the history
* emscripten: cleanup formula
  The emscripten depends on a non-stable build of llvm, and is therefore
  packaged with with the required llvm build.

  This commit does the following:
  - removes unnecessary build targets in the llvm project
  - adds a test that the llvm dependencies were in fact built
  - declares a dependency on libffi [*]
  - makes llvm build commands consistent with llvm formula

  Until #63183, the
  emscripten installation used nearly 2GB of storage space. Some
  improvements were made in that PR, and this commit is meant to follow
  through on that.

  [*] The arguments to cmake already previously referred to the libffi
  formula. It wasn't declared as a dependency, so the llvm install linked
  with the built-in libffi.
* Fix build
* Minimise llvm build size
  The added cmake flags are documented here:

  https://llvm.org/docs/BuildingADistribution.html#options-for-reducing-size
* Remove llvm tests
  They keep failing for some reason, even if it appears llvm built
  properly. Not really sure what's going on.

Closes #65799.

Signed-off-by: Sean Molenaar <[email protected]>
Signed-off-by: BrewTestBot <[email protected]>
  • Loading branch information
carlocab authored and BrewTestBot committed Dec 3, 2020
1 parent a4d0277 commit 006c33e
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions Formula/emscripten.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Emscripten < Formula

depends_on "cmake" => :build
depends_on "binaryen"
# error "fatal error: '__config' file not found" when building llvm 12 on High Sierra
depends_on "node"
depends_on "[email protected]"
depends_on "yuicompressor"
Expand All @@ -49,17 +48,17 @@ def install
# repository.
libexec.install Dir["*"]

# emscripten needs an llvm build with the following executables:
# https://github.com/emscripten-core/emscripten/blob/#{version}/docs/packaging.md#dependencies
resource("llvm").stage do
projects = %w[
clang
lld
]

runtimes = %w[
compiler-rt
libcxx
libcxxabi
libunwind
targets = %w[
host
WebAssembly
]

llvmpath = Pathname.pwd/"llvm"
Expand All @@ -77,29 +76,12 @@ def install
args = std_cmake_args.reject { |s| s["CMAKE_INSTALL_PREFIX"] } + %W[
-DCMAKE_INSTALL_PREFIX=#{libexec}/llvm
-DLLVM_ENABLE_PROJECTS=#{projects.join(";")}
-DLLVM_ENABLE_RUNTIMES=#{runtimes.join(";")}
-DLLVM_BUILD_EXTERNAL_COMPILER_RT=ON
-DLLVM_TARGETS_TO_BUILD=#{targets.join(";")}
-DLLVM_LINK_LLVM_DYLIB=ON
-DLLVM_BUILD_LLVM_C_DYLIB=ON
-DLLVM_ENABLE_EH=ON
-DLLVM_ENABLE_FFI=ON
-DLLVM_ENABLE_LIBCXX=ON
-DLLVM_ENABLE_RTTI=ON
-DLLVM_INCLUDE_DOCS=OFF
-DLLVM_BUILD_LLVM_DYLIB=ON
-DLLVM_INCLUDE_EXAMPLES=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_INSTALL_UTILS=ON
-DLLVM_ENABLE_Z3_SOLVER=OFF
-DLLVM_OPTIMIZED_TABLEGEN=ON
-DLLVM_TARGETS_TO_BUILD=host;WebAssembly
-DFFI_INCLUDE_DIR=#{Formula["libffi"].opt_lib}/libffi-#{Formula["libffi"].version}/include
-DFFI_LIBRARY_DIR=#{Formula["libffi"].opt_lib}
-DLLVM_CREATE_XCODE_TOOLCHAIN=#{MacOS::Xcode.installed? ? "ON" : "OFF"}
-DLLDB_USE_SYSTEM_DEBUGSERVER=ON
-DLLDB_ENABLE_PYTHON=OFF
-DLLDB_ENABLE_LUA=OFF
-DLLDB_ENABLE_LZMA=OFF
-DLIBOMP_INSTALL_ALIASES=OFF
-DCLANG_INCLUDE_TESTS=OFF
-DLLVM_INSTALL_UTILS=OFF
]

sdk = MacOS.sdk_path_if_needed
Expand All @@ -113,9 +95,8 @@ def install

mkdir llvmpath/"build" do
system "cmake", "-G", "Unix Makefiles", "..", *args
system "make"
system "make", "install"
system "make", "install-xcode-toolchain" if MacOS::Xcode.installed?
system "cmake", "--build", "."
system "cmake", "--build", ".", "--target", "install"
end
end

Expand Down

0 comments on commit 006c33e

Please sign in to comment.