From 437498709be14f4ab39545d1d70ec61934aefa5f Mon Sep 17 00:00:00 2001 From: Anutosh Bhat Date: Sat, 21 Dec 2024 22:42:45 +0530 Subject: [PATCH] Add patch on llvm 19.1.6 to take care of temporary files generated at runtime (#1476) * Add patch on llvm 19.1.6 to take care of temporary files generated at runtime * changes as per Martin's Suggestion --- recipes/recipes_emscripten/llvm/build.sh | 9 ++++----- .../shift_temporary_files_to_tmp_dir.patch | 15 +++++++++++++++ recipes/recipes_emscripten/llvm/recipe.yaml | 3 ++- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 recipes/recipes_emscripten/llvm/patches/shift_temporary_files_to_tmp_dir.patch diff --git a/recipes/recipes_emscripten/llvm/build.sh b/recipes/recipes_emscripten/llvm/build.sh index 8557f4d88..5faf9a24f 100644 --- a/recipes/recipes_emscripten/llvm/build.sh +++ b/recipes/recipes_emscripten/llvm/build.sh @@ -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 \ @@ -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 \ No newline at end of file diff --git a/recipes/recipes_emscripten/llvm/patches/shift_temporary_files_to_tmp_dir.patch b/recipes/recipes_emscripten/llvm/patches/shift_temporary_files_to_tmp_dir.patch new file mode 100644 index 000000000..32ac45c13 --- /dev/null +++ b/recipes/recipes_emscripten/llvm/patches/shift_temporary_files_to_tmp_dir.patch @@ -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); diff --git a/recipes/recipes_emscripten/llvm/recipe.yaml b/recipes/recipes_emscripten/llvm/recipe.yaml index 511a1631f..2e92fd7b8 100644 --- a/recipes/recipes_emscripten/llvm/recipe.yaml +++ b/recipes/recipes_emscripten/llvm/recipe.yaml @@ -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: