Skip to content

Commit

Permalink
Add patch on llvm 19.1.6 to take care of temporary files generated at…
Browse files Browse the repository at this point in the history
… runtime (#1476)

* Add patch on llvm 19.1.6 to take care of temporary files generated at runtime

* changes as per Martin's Suggestion
  • Loading branch information
anutosh491 authored Dec 21, 2024
1 parent 49bda97 commit 4374987
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
9 changes: 4 additions & 5 deletions recipes/recipes_emscripten/llvm/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@ export CMAKE_SYSTEM_PREFIX_PATH=$PREFIX
# clear LDFLAGS flags because they contain sWASM_BIGINT
export LDFLAGS=""


# Configure step
cmake ${CMAKE_ARGS} -S ../llvm -B . \
emcmake cmake ${CMAKE_ARGS} -S ../llvm -B . \
-DCMAKE_BUILD_TYPE=MinSizeRel \
-DCMAKE_PREFIX_PATH=$PREFIX \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DLLVM_HOST_TRIPLE=wasm32-unknown-emscripten \
-DLLVM_TARGETS_TO_BUILD="WebAssembly" \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_INCLUDE_BENCHMARKS=OFF \
-DLLVM_INCLUDE_EXAMPLES=OFF \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_PROJECTS="clang;lld" \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DLLVM_ENABLE_THREADS=OFF \
-DLLVM_ENABLE_ZSTD=OFF \
-DLLVM_ENABLE_LIBXML2=OFF \
Expand All @@ -30,10 +29,10 @@ cmake ${CMAKE_ARGS} -S ../llvm -B . \
-DCMAKE_CXX_FLAGS="-Dwait4=__syscall_wait4"

# Build step
make -j4
emmake make -j4

# Install step
make install
emmake make install

# Copy all files with ".wasm" extension to $PREFIX/bin
cp $SRC_DIR/build/bin/*.wasm $PREFIX/bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
diff --git a/clang/lib/Interpreter/Wasm.cpp b/clang/lib/Interpreter/Wasm.cpp
index aa10b160ccf8..184867e2b55f 100644
--- a/clang/lib/Interpreter/Wasm.cpp
+++ b/clang/lib/Interpreter/Wasm.cpp
@@ -76,8 +76,8 @@ llvm::Error WasmIncrementalExecutor::addModule(PartialTranslationUnit &PTU) {
llvm::TargetMachine *TargetMachine = Target->createTargetMachine(
PTU.TheModule->getTargetTriple(), "", "", TO, llvm::Reloc::Model::PIC_);
PTU.TheModule->setDataLayout(TargetMachine->createDataLayout());
- std::string ObjectFileName = PTU.TheModule->getName().str() + ".o";
- std::string BinaryFileName = PTU.TheModule->getName().str() + ".wasm";
+ std::string ObjectFileName = "/tmp/" + PTU.TheModule->getName().str() + ".o";
+ std::string BinaryFileName = "/tmp/" + PTU.TheModule->getName().str() + ".wasm";

std::error_code Error;
llvm::raw_fd_ostream ObjectFileOutput(llvm::StringRef(ObjectFileName), Error);
3 changes: 2 additions & 1 deletion recipes/recipes_emscripten/llvm/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ source:
sha256: f07fdcbb27b2b67aa95e5ddadf45406b33228481c250e65175066d36536a1ee2
patches:
- patches/cross_compile.patch
- patches/shift_temporary_files_to_tmp_dir.patch

build:
number: 0
number: 1

requirements:
build:
Expand Down

0 comments on commit 4374987

Please sign in to comment.