summaryrefslogtreecommitdiffstats
path: root/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 11:19:16 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-24 09:53:24 +0000
commitb5f8ee61a7f7e9bd291dd26b0585d03eb686c941 (patch)
treed4d31289c39fc00da064a825df13a0b98ce95b10 /fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler
parentAdding upstream version 1.44.3. (diff)
downloadnetdata-b5f8ee61a7f7e9bd291dd26b0585d03eb686c941.tar.xz
netdata-b5f8ee61a7f7e9bd291dd26b0585d03eb686c941.zip
Adding upstream version 1.46.3.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler')
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/CMakeLists.txt299
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/README.md32
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.py14
-rwxr-xr-xfluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.sh7
-rwxr-xr-xfluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_arc.sh7
-rwxr-xr-xfluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_xtensa.sh7
-rw-r--r--fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/main.c451
7 files changed, 0 insertions, 817 deletions
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/CMakeLists.txt b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/CMakeLists.txt
deleted file mode 100644
index 0ae821af6..000000000
--- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/CMakeLists.txt
+++ /dev/null
@@ -1,299 +0,0 @@
-# Copyright (C) 2019 Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-cmake_minimum_required (VERSION 3.14)
-
-include(CheckPIESupported)
-
-if (NOT DEFINED WAMR_BUILD_PLATFORM)
- if (CMAKE_SYSTEM_NAME)
- string(TOLOWER ${CMAKE_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
- else()
- string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} WAMR_BUILD_PLATFORM)
- endif()
-endif()
-
-if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
- project (aot-compiler)
-else()
- project (aot-compiler C ASM CXX)
- enable_language (ASM_MASM)
- add_definitions(-DCOMPILING_WASM_RUNTIME_API=1)
-endif()
-
-set (CMAKE_CXX_STANDARD 14)
-
-if (NOT DEFINED WAMR_BUILD_PLATFORM)
- set (WAMR_BUILD_PLATFORM "linux")
-endif()
-
-# Reset default linker flags
-set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
-set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "")
-
-add_definitions(-DWASM_ENABLE_INTERP=1)
-add_definitions(-DWASM_ENABLE_WAMR_COMPILER=1)
-add_definitions(-DWASM_ENABLE_BULK_MEMORY=1)
-add_definitions(-DWASM_DISABLE_HW_BOUND_CHECK=1)
-add_definitions(-DWASM_ENABLE_SHARED_MEMORY=1)
-add_definitions(-DWASM_ENABLE_THREAD_MGR=1)
-add_definitions(-DWASM_ENABLE_TAIL_CALL=1)
-add_definitions(-DWASM_ENABLE_SIMD=1)
-add_definitions(-DWASM_ENABLE_REF_TYPES=1)
-add_definitions(-DWASM_ENABLE_CUSTOM_NAME_SECTION=1)
-add_definitions(-DWASM_ENABLE_DUMP_CALL_STACK=1)
-add_definitions(-DWASM_ENABLE_PERF_PROFILING=1)
-add_definitions(-DWASM_ENABLE_LOAD_CUSTOM_SECTION=1)
-add_definitions(-DWASM_ENABLE_LIB_WASI_THREADS=1)
-
-if (WAMR_BUILD_LLVM_LEGACY_PM EQUAL 1)
- add_definitions(-DWASM_ENABLE_LLVM_LEGACY_PM=1)
-endif()
-
-if (DEFINED WAMR_BUILD_AOT_FUNC_PREFIX)
- add_definitions(-DAOT_FUNC_PREFIX="${WAMR_BUILD_AOT_FUNC_PREFIX}")
-endif ()
-
-# Set WAMR_BUILD_TARGET, currently values supported:
-# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
-if (NOT WAMR_BUILD_TARGET)
- if (CMAKE_SIZEOF_VOID_P EQUAL 8)
- # Build as X86_64 by default in 64-bit platform
- set (WAMR_BUILD_TARGET "X86_64")
- else ()
- # Build as X86_32 by default in 32-bit platform
- set (WAMR_BUILD_TARGET "X86_32")
- endif ()
- if (WAMR_BUILD_PLATFORM STREQUAL "windows")
- if (("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win32"))
- set (WAMR_BUILD_TARGET "X86_32")
- endif()
- elseif (WAMR_BUILD_PLATFORM STREQUAL "darwin")
- if (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
- set (WAMR_BUILD_TARGET "AARCH64")
- endif ()
- endif()
-endif ()
-
-string(TOUPPER ${WAMR_BUILD_TARGET} WAMR_BUILD_TARGET)
-
-# Add definitions for the build target
-if (WAMR_BUILD_TARGET STREQUAL "X86_64")
- add_definitions(-DBUILD_TARGET_X86_64)
-elseif (WAMR_BUILD_TARGET STREQUAL "AMD_64")
- add_definitions(-DBUILD_TARGET_AMD_64)
-elseif (WAMR_BUILD_TARGET STREQUAL "X86_32")
- add_definitions(-DBUILD_TARGET_X86_32)
-elseif (WAMR_BUILD_TARGET MATCHES "AARCH64.*")
- add_definitions(-DBUILD_TARGET_AARCH64)
- add_definitions(-DBUILD_TARGET="${WAMR_BUILD_TARGET}")
-elseif (WAMR_BUILD_TARGET MATCHES "ARM.*")
- add_definitions(-DBUILD_TARGET_ARM)
- add_definitions(-DBUILD_TARGET="${WAMR_BUILD_TARGET}")
-elseif (WAMR_BUILD_TARGET STREQUAL "RISCV64" OR WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64D")
- add_definitions(-DBUILD_TARGET_RISCV64_LP64D)
-elseif (WAMR_BUILD_TARGET STREQUAL "RISCV64_LP64")
- add_definitions(-DBUILD_TARGET_RISCV64_LP64)
-elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32" OR WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32D")
- add_definitions(-DBUILD_TARGET_RISCV32_ILP32D)
-elseif (WAMR_BUILD_TARGET STREQUAL "RISCV32_ILP32")
- add_definitions(-DBUILD_TARGET_RISCV32_ILP32)
-else ()
- message (FATAL_ERROR "-- Build target isn't set")
-endif ()
-
-message ("-- Build as target ${WAMR_BUILD_TARGET}")
-
-if (CMAKE_SIZEOF_VOID_P EQUAL 8)
- if (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64"
- OR WAMR_BUILD_TARGET MATCHES "AARCH64.*" OR WAMR_BUILD_TARGET MATCHES "RISCV64.*")
- if (NOT WAMR_BUILD_PLATFORM STREQUAL "windows")
- # Add -fPIC flag if build as 64-bit
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
- set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -fPIC")
- set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -fPIC")
- endif ()
- else ()
- add_definitions (-m32)
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32")
- set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -m32")
- endif ()
-endif ()
-
-if (NOT CMAKE_BUILD_TYPE)
- set(CMAKE_BUILD_TYPE Release)
-endif (NOT CMAKE_BUILD_TYPE)
-message ("-- CMAKE_BUILD_TYPE = " ${CMAKE_BUILD_TYPE})
-
-if (CMAKE_BUILD_TYPE STREQUAL "Debug")
- add_definitions(-DBH_DEBUG=1)
-endif ()
-if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
- add_definitions(-DWASM_ENABLE_DEBUG_AOT=1)
-endif()
-
-# Enable LLVM
-if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
- set (LLVM_SRC_ROOT "${PROJECT_SOURCE_DIR}/../core/deps/llvm")
- if (WAMR_BUILD_PLATFORM STREQUAL "windows")
- if (NOT EXISTS "${LLVM_SRC_ROOT}/win32build")
- message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/win32build")
- endif ()
- set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/win32build;${CMAKE_PREFIX_PATH}")
- else()
- if (NOT EXISTS "${LLVM_SRC_ROOT}/build")
- message (FATAL_ERROR "Cannot find LLVM dir: ${LLVM_SRC_ROOT}/build")
- endif ()
- set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
- endif ()
-endif ()
-
-find_package(LLVM REQUIRED CONFIG)
-include_directories(${LLVM_INCLUDE_DIRS})
-add_definitions(${LLVM_DEFINITIONS})
-
-message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
-message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
-
-if (WAMR_BUILD_DEBUG_AOT EQUAL 1)
- if(LLVM_BUILD_MAIN_SRC_DIR)
- include_directories(${LLVM_BUILD_MAIN_SRC_DIR}/../lldb/include)
- include_directories(${LLVM_BUILD_BINARY_DIR}/tools/lldb/include)
- endif()
- link_directories(${LLVM_LIBRARY_DIRS})
- find_library(lib_lldb NAMES lldb HINTS ${LLVM_LIBRARY_DIRS} REQUIRED)
- message(STATUS "find lldb ${LLDB_ALL_PLUGINS} in: ${LLVM_LIBRARY_DIRS}")
-endif()
-
-if ("$ENV{COLLECT_CODE_COVERAGE}" STREQUAL "1" OR COLLECT_CODE_COVERAGE EQUAL 1)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
- message ("-- Collect code coverage enabled")
-endif ()
-
-if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang"))
- if(NOT MSVC)
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
- else()
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
- endif()
-endif()
-
-if (NOT MSVC)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security \
- -ffunction-sections -fdata-sections \
- -Wno-unused-parameter -Wno-pedantic")
- # Remove the extra spaces for better make log
- string (REGEX REPLACE " *" " " CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
-endif()
-
-set (SHARED_DIR ../core/shared)
-set (IWASM_DIR ../core/iwasm)
-set (APP_FRAMEWORK_DIR ../core/app-framework)
-
-include_directories (${SHARED_DIR}/include
- ${IWASM_DIR}/include)
-
-enable_language (ASM)
-
-include (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake)
-include (${SHARED_DIR}/mem-alloc/mem_alloc.cmake)
-include (${SHARED_DIR}/utils/shared_utils.cmake)
-include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake)
-include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
-include (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake)
-if (NOT MINGW)
- if (NOT MSVC)
- include (${IWASM_DIR}/libraries/libc-wasi/libc_wasi.cmake)
- else()
- include (${IWASM_DIR}/libraries/libc-uvwasi/libc_uvwasi.cmake)
- endif()
-endif()
-include (${IWASM_DIR}/libraries/lib-pthread/lib_pthread.cmake)
-include (${IWASM_DIR}/libraries/lib-wasi-threads/lib_wasi_threads.cmake)
-include (${IWASM_DIR}/common/iwasm_common.cmake)
-include (${IWASM_DIR}/interpreter/iwasm_interp.cmake)
-include (${IWASM_DIR}/aot/iwasm_aot.cmake)
-include (${IWASM_DIR}/compilation/iwasm_compl.cmake)
-
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion")
-if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
- if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang" OR MSVC))
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch-register")
- # UNDEFINED BEHAVIOR, refer to https://en.cppreference.com/w/cpp/language/ub
- if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT WAMR_BUILD_JIT EQUAL 1)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined \
- -fno-sanitize=bounds,bounds-strict,alignment \
- -fno-sanitize-recover")
- set(lib_ubsan -fsanitize=undefined)
- endif()
- else ()
- # UNDEFINED BEHAVIOR, refer to https://en.cppreference.com/w/cpp/language/ub
- if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND NOT WAMR_BUILD_JIT EQUAL 1)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined \
- -fno-sanitize=bounds,alignment \
- -fno-sanitize-recover")
- set(lib_ubsan -fsanitize=undefined)
- endif()
- endif()
-endif ()
-
-if (NOT MSVC)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector-strong --param ssp-buffer-size=4")
-endif()
-
-# We disable these flags by default to stay the same with wasm runtime
-# set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mindirect-branch=thunk -mfunction-return=thunk")
-
-if (NOT MSVC)
- add_definitions(-D_FORTIFY_SOURCE=2)
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftrapv")
-endif()
-
-if (WIN32)
- add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
-endif()
-
-# message ("-- CMAKE_C_FLAGS: ${CMAKE_C_FLAGS}")
-
-add_library (vmlib
- ${PLATFORM_SHARED_SOURCE}
- ${MEM_ALLOC_SHARED_SOURCE}
- ${UTILS_SHARED_SOURCE}
- ${UNCOMMON_SHARED_SOURCE}
- ${THREAD_MGR_SOURCE}
- ${LIBC_BUILTIN_SOURCE}
- ${LIBC_WASI_SOURCE}
- ${LIB_PTHREAD_SOURCE}
- ${LIB_WASI_THREADS_SOURCE}
- ${IWASM_COMMON_SOURCE}
- ${IWASM_INTERP_SOURCE}
- ${IWASM_AOT_SOURCE})
-
-add_library (aotclib ${IWASM_COMPL_SOURCE})
-
-add_executable (wamrc main.c)
-check_pie_supported()
-set_target_properties (wamrc PROPERTIES POSITION_INDEPENDENT_CODE ON)
-
-if (LLVM_LINK_LLVM_DYLIB)
- set(WAMRC_LINK_LLVM_LIBS LLVM)
-else()
- set(WAMRC_LINK_LLVM_LIBS ${LLVM_AVAILABLE_LIBS})
-endif()
-
-if (NOT MSVC)
- target_link_libraries (wamrc aotclib vmlib ${WAMRC_LINK_LLVM_LIBS} ${lib_ubsan}
- -lm -lpthread ${lib_lldb} ${UV_A_LIBS})
- if (MINGW)
- target_link_libraries (wamrc ssp.a ws2_32)
- else()
- target_link_libraries (wamrc -ldl)
- endif()
-else()
- target_link_libraries (wamrc aotclib vmlib ${lib_lldb} ${WAMRC_LINK_LLVM_LIBS} ${lib_ubsan}
- ${UV_A_LIBS})
-endif()
-
-install (TARGETS wamrc DESTINATION bin)
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/README.md b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/README.md
deleted file mode 100644
index b9e566af2..000000000
--- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-
-### Build wamrc AOT compiler
-
-Both wasm binary file and AOT file are supported by iwasm. The wamrc AOT compiler is to compile wasm binary file to AOT file which can also be run by iwasm. You can execute following commands to build **wamrc** compiler:
-
-For **Linux**(Ubuntu 20.04 as an example):
-
-First, make sure necessary dependency are installed:
-
-```shell
-sudo apt-get install git build-essential cmake g++-multilib libgcc-9-dev lib32gcc-9-dev ccache
-```
-
-```shell
-cd wamr-compiler
-./build_llvm.sh (or "./build_llvm_xtensa.sh" to support xtensa target)
-mkdir build && cd build
-cmake .. (or "cmake .. -DWAMR_BUILD_PLATFORM=darwin" for MacOS)
-make
-# wamrc is generated under current directory
-```
-
-For **Windows**:
-
-```shell
-cd wamr-compiler
-python build_llvm.py
-mkdir build && cd build
-cmake ..
-cmake --build . --config Release
-# wamrc.exe is generated under .\Release directory
-```
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.py b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.py
deleted file mode 100644
index 6597f61a8..000000000
--- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.py
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright (C) 2019 Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-#
-
-import pathlib
-import subprocess
-import sys
-
-script = (
- pathlib.Path(__file__).parent.joinpath("../build-scripts/build_llvm.py").resolve()
-)
-subprocess.check_call([sys.executable, script])
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.sh
deleted file mode 100755
index c3ec54b61..000000000
--- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2020 Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
-/usr/bin/env python3 ../build-scripts/build_llvm.py "$@"
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_arc.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_arc.sh
deleted file mode 100755
index d148e11ec..000000000
--- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_arc.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2020 Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
-/usr/bin/env python3 ../build-scripts/build_llvm.py --platform arc "$@"
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_xtensa.sh b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_xtensa.sh
deleted file mode 100755
index 183ea379f..000000000
--- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/build_llvm_xtensa.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/sh
-
-# Copyright (C) 2020 Intel Corporation. All rights reserved.
-# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
-/usr/bin/env python3 -m pip install --user -r ../build-scripts/requirements.txt
-/usr/bin/env python3 ../build-scripts/build_llvm.py --platform xtensa "$@"
diff --git a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/main.c b/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/main.c
deleted file mode 100644
index bd8691c4b..000000000
--- a/fluent-bit/lib/wasm-micro-runtime-WAMR-1.2.2/wamr-compiler/main.c
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Copyright (C) 2019 Intel Corporation. All rights reserved.
- * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- */
-
-#include <stdlib.h>
-#include "bh_platform.h"
-#include "bh_read_file.h"
-#include "wasm_export.h"
-#include "aot_export.h"
-
-/* clang-format off */
-static void
-print_help()
-{
- printf("Usage: wamrc [options] -o output_file wasm_file\n");
- printf(" --target=<arch-name> Set the target arch, which has the general format: <arch><sub>\n");
- printf(" <arch> = x86_64, i386, aarch64, arm, thumb, xtensa, mips,\n");
- printf(" riscv64, riscv32.\n");
- printf(" Default is host arch, e.g. x86_64\n");
- printf(" <sub> = for ex. on arm or thumb: v5, v6m, v7a, v7m, etc.\n");
- printf(" Use --target=help to list supported targets\n");
- printf(" --target-abi=<abi> Set the target ABI, e.g. gnu, eabi, gnueabihf, msvc, etc.\n");
- printf(" Default is gnu if target isn't riscv64 or riscv32\n");
- printf(" For target riscv64 and riscv32, default is lp64d and ilp32d\n");
- printf(" Use --target-abi=help to list all the ABI supported\n");
- printf(" --cpu=<cpu> Set the target CPU (default: host CPU, e.g. skylake)\n");
- printf(" Use --cpu=help to list all the CPU supported\n");
- printf(" --cpu-features=<features> Enable or disable the CPU features\n");
- printf(" Use +feature to enable a feature, or -feature to disable it\n");
- printf(" For example, --cpu-features=+feature1,-feature2\n");
- printf(" Use --cpu-features=+help to list all the features supported\n");
- printf(" --opt-level=n Set the optimization level (0 to 3, default is 3)\n");
- printf(" --size-level=n Set the code size level (0 to 3, default is 3)\n");
- printf(" -sgx Generate code for SGX platform (Intel Software Guard Extention)\n");
- printf(" --bounds-checks=1/0 Enable or disable the bounds checks for memory access:\n");
- printf(" by default it is disabled in all 64-bit platforms except SGX and\n");
- printf(" in these platforms runtime does bounds checks with hardware trap,\n");
- printf(" and by default it is enabled in all 32-bit platforms\n");
- printf(" --stack-bounds-checks=1/0 Enable or disable the bounds checks for native stack:\n");
- printf(" if the option isn't set, the status is same as `--bounds-check`,\n");
- printf(" if the option is set:\n");
- printf(" (1) it is always enabled when `--bounds-checks` is enabled,\n");
- printf(" (2) else it is enabled/disabled according to the option value\n");
- printf(" --stack-usage=<file> Generate a stack-usage file.\n");
- printf(" Similarly to `clang -fstack-usage`.\n");
- printf(" --format=<format> Specifies the format of the output file\n");
- printf(" The format supported:\n");
- printf(" aot (default) AoT file\n");
- printf(" object Native object file\n");
- printf(" llvmir-unopt Unoptimized LLVM IR\n");
- printf(" llvmir-opt Optimized LLVM IR\n");
- printf(" --disable-bulk-memory Disable the MVP bulk memory feature\n");
- printf(" --enable-multi-thread Enable multi-thread feature, the dependent features bulk-memory and\n");
- printf(" thread-mgr will be enabled automatically\n");
- printf(" --enable-tail-call Enable the post-MVP tail call feature\n");
- printf(" --disable-simd Disable the post-MVP 128-bit SIMD feature:\n");
- printf(" currently 128-bit SIMD is supported for x86-64 and aarch64 targets,\n");
- printf(" and by default it is enabled in them and disabled in other targets\n");
- printf(" --disable-ref-types Disable the MVP reference types feature\n");
- printf(" --disable-aux-stack-check Disable auxiliary stack overflow/underflow check\n");
- printf(" --enable-dump-call-stack Enable stack trace feature\n");
- printf(" --enable-perf-profiling Enable function performance profiling\n");
- printf(" --enable-memory-profiling Enable memory usage profiling\n");
- printf(" --enable-indirect-mode Enalbe call function through symbol table but not direct call\n");
- printf(" --disable-llvm-intrinsics Disable the LLVM built-in intrinsics\n");
- printf(" --disable-llvm-lto Disable the LLVM link time optimization\n");
- printf(" --emit-custom-sections=<section names>\n");
- printf(" Emit the specified custom sections to AoT file, using comma to separate\n");
- printf(" multiple names, e.g.\n");
- printf(" --emit-custom-sections=section1,section2,sectionN\n");
- printf(" -v=n Set log verbose level (0 to 5, default is 2), larger with more log\n");
- printf(" --version Show version information\n");
- printf("Examples: wamrc -o test.aot test.wasm\n");
- printf(" wamrc --target=i386 -o test.aot test.wasm\n");
- printf(" wamrc --target=i386 --format=object -o test.o test.wasm\n");
-}
-/* clang-format on */
-
-#define PRINT_HELP_AND_EXIT() \
- do { \
- print_help(); \
- goto fail0; \
- } while (0)
-
-/**
- * Split a strings into an array of strings
- * Returns NULL on failure
- * Memory must be freed by caller
- * Based on: http://stackoverflow.com/a/11198630/471795
- */
-static char **
-split_string(char *str, int *count, const char *delimer)
-{
- char **res = NULL, **res1;
- char *p;
- int idx = 0;
-
- /* split string and append tokens to 'res' */
- do {
- p = strtok(str, delimer);
- str = NULL;
- res1 = res;
- res = (char **)realloc(res1, sizeof(char *) * (uint32)(idx + 1));
- if (res == NULL) {
- free(res1);
- return NULL;
- }
- res[idx++] = p;
- } while (p);
-
- /**
- * Due to the section name,
- * res[0] might contain a '\' to indicate a space
- * func\name -> func name
- */
- p = strchr(res[0], '\\');
- while (p) {
- *p = ' ';
- p = strchr(p, '\\');
- }
-
- if (count) {
- *count = idx - 1;
- }
- return res;
-}
-
-int
-main(int argc, char *argv[])
-{
- char *wasm_file_name = NULL, *out_file_name = NULL;
- uint8 *wasm_file = NULL;
- uint32 wasm_file_size;
- wasm_module_t wasm_module = NULL;
- aot_comp_data_t comp_data = NULL;
- aot_comp_context_t comp_ctx = NULL;
- RuntimeInitArgs init_args;
- AOTCompOption option = { 0 };
- char error_buf[128];
- int log_verbose_level = 2;
- bool sgx_mode = false, size_level_set = false;
- int exit_status = EXIT_FAILURE;
-
- option.opt_level = 3;
- option.size_level = 3;
- option.output_format = AOT_FORMAT_FILE;
- /* default value, enable or disable depends on the platform */
- option.bounds_checks = 2;
- /* default value, enable or disable depends on the platform */
- option.stack_bounds_checks = 2;
- option.enable_simd = true;
- option.enable_aux_stack_check = true;
- option.enable_bulk_memory = true;
- option.enable_ref_types = true;
-
- /* Process options */
- for (argc--, argv++; argc > 0 && argv[0][0] == '-'; argc--, argv++) {
- if (!strcmp(argv[0], "-o")) {
- argc--, argv++;
- if (argc < 2)
- PRINT_HELP_AND_EXIT();
- out_file_name = argv[0];
- }
- else if (!strncmp(argv[0], "--target=", 9)) {
- if (argv[0][9] == '\0')
- PRINT_HELP_AND_EXIT();
- option.target_arch = argv[0] + 9;
- }
- else if (!strncmp(argv[0], "--target-abi=", 13)) {
- if (argv[0][13] == '\0')
- PRINT_HELP_AND_EXIT();
- option.target_abi = argv[0] + 13;
- }
- else if (!strncmp(argv[0], "--cpu=", 6)) {
- if (argv[0][6] == '\0')
- PRINT_HELP_AND_EXIT();
- option.target_cpu = argv[0] + 6;
- }
- else if (!strncmp(argv[0], "--cpu-features=", 15)) {
- if (argv[0][15] == '\0')
- PRINT_HELP_AND_EXIT();
- option.cpu_features = argv[0] + 15;
- }
- else if (!strncmp(argv[0], "--opt-level=", 12)) {
- if (argv[0][12] == '\0')
- PRINT_HELP_AND_EXIT();
- option.opt_level = (uint32)atoi(argv[0] + 12);
- if (option.opt_level > 3)
- option.opt_level = 3;
- }
- else if (!strncmp(argv[0], "--size-level=", 13)) {
- if (argv[0][13] == '\0')
- PRINT_HELP_AND_EXIT();
- option.size_level = (uint32)atoi(argv[0] + 13);
- if (option.size_level > 3)
- option.size_level = 3;
- size_level_set = true;
- }
- else if (!strcmp(argv[0], "-sgx")) {
- sgx_mode = true;
- }
- else if (!strncmp(argv[0], "--bounds-checks=", 16)) {
- option.bounds_checks = (atoi(argv[0] + 16) == 1) ? 1 : 0;
- }
- else if (!strncmp(argv[0], "--stack-bounds-checks=", 22)) {
- option.stack_bounds_checks = (atoi(argv[0] + 22) == 1) ? 1 : 0;
- }
- else if (!strncmp(argv[0], "--stack-usage=", 14)) {
- option.stack_usage_file = argv[0] + 14;
- }
- else if (!strncmp(argv[0], "--format=", 9)) {
- if (argv[0][9] == '\0')
- PRINT_HELP_AND_EXIT();
- if (!strcmp(argv[0] + 9, "aot"))
- option.output_format = AOT_FORMAT_FILE;
- else if (!strcmp(argv[0] + 9, "object"))
- option.output_format = AOT_OBJECT_FILE;
- else if (!strcmp(argv[0] + 9, "llvmir-unopt"))
- option.output_format = AOT_LLVMIR_UNOPT_FILE;
- else if (!strcmp(argv[0] + 9, "llvmir-opt"))
- option.output_format = AOT_LLVMIR_OPT_FILE;
- else {
- printf("Invalid format %s.\n", argv[0] + 9);
- PRINT_HELP_AND_EXIT();
- }
- }
- else if (!strncmp(argv[0], "-v=", 3)) {
- log_verbose_level = atoi(argv[0] + 3);
- if (log_verbose_level < 0 || log_verbose_level > 5)
- PRINT_HELP_AND_EXIT();
- }
- else if (!strcmp(argv[0], "--disable-bulk-memory")) {
- option.enable_bulk_memory = false;
- }
- else if (!strcmp(argv[0], "--enable-multi-thread")) {
- option.enable_bulk_memory = true;
- option.enable_thread_mgr = true;
- option.enable_ref_types = false;
- }
- else if (!strcmp(argv[0], "--enable-tail-call")) {
- option.enable_tail_call = true;
- }
- else if (!strcmp(argv[0], "--enable-simd")) {
- /* obsolete option, kept for compatibility */
- option.enable_simd = true;
- }
- else if (!strcmp(argv[0], "--disable-simd")) {
- option.enable_simd = false;
- }
- else if (!strcmp(argv[0], "--disable-ref-types")) {
- option.enable_ref_types = false;
- }
- else if (!strcmp(argv[0], "--disable-aux-stack-check")) {
- option.enable_aux_stack_check = false;
- }
- else if (!strcmp(argv[0], "--enable-dump-call-stack")) {
- option.enable_aux_stack_frame = true;
- }
- else if (!strcmp(argv[0], "--enable-perf-profiling")) {
- option.enable_aux_stack_frame = true;
- }
- else if (!strcmp(argv[0], "--enable-memory-profiling")) {
- option.enable_stack_estimation = true;
- }
- else if (!strcmp(argv[0], "--enable-indirect-mode")) {
- option.is_indirect_mode = true;
- }
- else if (!strcmp(argv[0], "--disable-llvm-intrinsics")) {
- option.disable_llvm_intrinsics = true;
- }
- else if (!strcmp(argv[0], "--disable-llvm-lto")) {
- option.disable_llvm_lto = true;
- }
- else if (!strncmp(argv[0], "--emit-custom-sections=", 23)) {
- int len = 0;
- if (option.custom_sections) {
- free(option.custom_sections);
- }
-
- option.custom_sections = split_string(argv[0] + 23, &len, ",");
- if (!option.custom_sections) {
- printf("Failed to process emit-custom-sections: alloc "
- "memory failed\n");
- PRINT_HELP_AND_EXIT();
- }
-
- option.custom_sections_count = len;
- }
- else if (!strncmp(argv[0], "--version", 9)) {
- uint32 major, minor, patch;
- wasm_runtime_get_version(&major, &minor, &patch);
- printf("wamrc %u.%u.%u\n", major, minor, patch);
- return 0;
- }
- else
- PRINT_HELP_AND_EXIT();
- }
-
- if (argc == 0 || !out_file_name)
- PRINT_HELP_AND_EXIT();
-
- if (!size_level_set) {
- /**
- * Set opt level to 1 by default for Windows and MacOS as
- * they can not memory map out 0-2GB memory and might not
- * be able to meet the requirements of some AOT relocation
- * operations.
- */
- if (option.target_abi && !strcmp(option.target_abi, "msvc")) {
- LOG_VERBOSE("Set size level to 1 for Windows AOT file");
- option.size_level = 1;
- }
-#if defined(_WIN32) || defined(_WIN32_) || defined(__APPLE__) \
- || defined(__MACH__)
- if (!option.target_abi) {
- LOG_VERBOSE("Set size level to 1 for Windows or MacOS AOT file");
- option.size_level = 1;
- }
-#endif
- }
-
- if (sgx_mode) {
- option.size_level = 1;
- option.is_sgx_platform = true;
- }
-
- wasm_file_name = argv[0];
-
- if (!strcmp(wasm_file_name, out_file_name)) {
- printf("Error: input file and output file are the same");
- return -1;
- }
-
- memset(&init_args, 0, sizeof(RuntimeInitArgs));
-
- init_args.mem_alloc_type = Alloc_With_Allocator;
- init_args.mem_alloc_option.allocator.malloc_func = malloc;
- init_args.mem_alloc_option.allocator.realloc_func = realloc;
- init_args.mem_alloc_option.allocator.free_func = free;
-
- /* initialize runtime environment */
- if (!wasm_runtime_full_init(&init_args)) {
- printf("Init runtime environment failed.\n");
- return -1;
- }
-
- bh_log_set_verbose_level(log_verbose_level);
-
- bh_print_time("Begin to load wasm file");
-
- /* load WASM byte buffer from WASM bin file */
- if (!(wasm_file =
- (uint8 *)bh_read_file_to_buffer(wasm_file_name, &wasm_file_size)))
- goto fail1;
-
- if (get_package_type(wasm_file, wasm_file_size) != Wasm_Module_Bytecode) {
- printf("Invalid file type: expected wasm file but got other\n");
- goto fail2;
- }
-
- /* load WASM module */
- if (!(wasm_module = wasm_runtime_load(wasm_file, wasm_file_size, error_buf,
- sizeof(error_buf)))) {
- printf("%s\n", error_buf);
- goto fail2;
- }
-
- if (!(comp_data = aot_create_comp_data(wasm_module))) {
- printf("%s\n", aot_get_last_error());
- goto fail3;
- }
-
-#if WASM_ENABLE_DEBUG_AOT != 0
- if (!create_dwarf_extractor(comp_data, wasm_file_name)) {
- printf("%s:create dwarf extractor failed\n", wasm_file_name);
- }
-#endif
-
- bh_print_time("Begin to create compile context");
-
- if (!(comp_ctx = aot_create_comp_context(comp_data, &option))) {
- printf("%s\n", aot_get_last_error());
- goto fail4;
- }
-
- bh_print_time("Begin to compile");
-
- if (!aot_compile_wasm(comp_ctx)) {
- printf("%s\n", aot_get_last_error());
- goto fail5;
- }
-
- switch (option.output_format) {
- case AOT_LLVMIR_UNOPT_FILE:
- case AOT_LLVMIR_OPT_FILE:
- if (!aot_emit_llvm_file(comp_ctx, out_file_name)) {
- printf("%s\n", aot_get_last_error());
- goto fail5;
- }
- break;
- case AOT_OBJECT_FILE:
- if (!aot_emit_object_file(comp_ctx, out_file_name)) {
- printf("%s\n", aot_get_last_error());
- goto fail5;
- }
- break;
- case AOT_FORMAT_FILE:
- if (!aot_emit_aot_file(comp_ctx, comp_data, out_file_name)) {
- printf("%s\n", aot_get_last_error());
- goto fail5;
- }
- break;
- default:
- break;
- }
-
- bh_print_time("Compile end");
-
- printf("Compile success, file %s was generated.\n", out_file_name);
- exit_status = EXIT_SUCCESS;
-
-fail5:
- /* Destroy compiler context */
- aot_destroy_comp_context(comp_ctx);
-
-fail4:
- /* Destroy compile data */
- aot_destroy_comp_data(comp_data);
-
-fail3:
- /* Unload WASM module */
- wasm_runtime_unload(wasm_module);
-
-fail2:
- /* free the file buffer */
- wasm_runtime_free(wasm_file);
-
-fail1:
- /* Destroy runtime environment */
- wasm_runtime_destroy();
-
-fail0:
- /* free option.custom_sections */
- if (option.custom_sections) {
- free(option.custom_sections);
- }
-
- bh_print_time("wamrc return");
- return exit_status;
-}