diff --git a/libASL/cpp_backend.ml b/libASL/cpp_backend.ml index 7091128a..a73348d2 100644 --- a/libASL/cpp_backend.ml +++ b/libASL/cpp_backend.ml @@ -391,8 +391,8 @@ let init_st (genfns: cpp_fun_sig list) prefix file = genvars; } let export_dir = "aslp/generated" -let gen_prefix = "aslp-lifter-gen/include" -let instantiate_prefix = "aslp-lifter-instantiate/src" +let gen_prefix = "aslp-lifter/include" +let instantiate_prefix = "aslp-lifter/src" let stdlib_deps = ["cassert"; "tuple"; "variant"; "vector"; "stdexcept"; "aslp/interface.hpp"] let global_deps = stdlib_deps @ [export_dir^"/aslp_lifter.hpp"] @@ -419,7 +419,7 @@ let write_test_file tests prefix dir = close_out st.oc; gens -(* Write the prefix decoder file *) +(* Write the decoder file *) let write_decoder_file fn fnsig genfns prefix dir = let m = name_of_FIdent fn in let path = dir ^ "/" ^ m ^ ".hpp" in diff --git a/offlineASL-cpp/build.sh b/offlineASL-cpp/build.sh index 1a716083..f22cb990 100755 --- a/offlineASL-cpp/build.sh +++ b/offlineASL-cpp/build.sh @@ -3,5 +3,12 @@ set -o pipefail # echo ":gen A64 aarch64_integer_arithmetic.+ cpp $(pwd)" | dune exec asli -echo ":gen A64 aarch64.+ cpp $(dirname "$0")" | dune exec asli +dir="$(dirname "$0")" +cd "$dir" +# echo ":gen A64 aarch64.+ cpp ./subprojects" | dune exec asli +meson setup --reconfigure build +pushd build +meson compile +DESTDIR=$(pwd)/prefix meson install +popd diff --git a/offlineASL-cpp/meson.build b/offlineASL-cpp/meson.build index f3e34412..e81190d3 100644 --- a/offlineASL-cpp/meson.build +++ b/offlineASL-cpp/meson.build @@ -1,6 +1,14 @@ project('offlineasl', 'cpp', version : '0.1', - default_options : ['warning_level=3', 'cpp_std=c++20']) + default_options : [ + 'warning_level=3', + 'cpp_std=c++20', + 'buildtype=debug', + 'strip=true', + ] +) -subproject('aslp-lifter-gen') +# debug(get_option('buildtype')) + +subproject('aslp-lifter') subproject('aslp-lifter-instantiate') diff --git a/offlineASL-cpp/subprojects/aslp-lifter-gen/CMakeLists.txt b/offlineASL-cpp/subprojects/aslp-lifter-gen/CMakeLists.txt deleted file mode 100644 index 857a4899..00000000 --- a/offlineASL-cpp/subprojects/aslp-lifter-gen/CMakeLists.txt +++ /dev/null @@ -1,76 +0,0 @@ -cmake_minimum_required(VERSION 3.20) - -project(offlineasl) - -include(../cmake/prelude.cmake) - -### aslp-lifter-gen ### -# provides templates to instantiate the lifter with generic targets - -add_library(aslp-lifter-gen INTERFACE) -target_include_directories(aslp-lifter-gen INTERFACE include) - -target_compile_options(aslp-lifter-gen INTERFACE -Wno-error=unused-variable -Wno-error=unused-function -Wno-error=unused-but-set-variable) -IF(CMAKE_BUILD_TYPE MATCHES DEBUG) - target_compile_options(aslp-lifter-gen INTERFACE -g -Ofast -fsanitize=address) - target_link_options(aslp-lifter-gen INTERFACE -g -Ofast -fsanitize=address) -ENDIF() - -install( - DIRECTORY include/ - DESTINATION ${CMAKE_INSTALL_FULL_INCLUDEDIR} - FILES_MATCHING PATTERN "*.hpp") -configure_file(aslp-lifter-gen.pc.in aslp-lifter-gen.pc @ONLY) -install(FILES ${CMAKE_CURRENT_BINARY_DIR}/aslp-lifter-gen.pc - DESTINATION ${CMAKE_INSTALL_FULL_DATAROOTDIR}/pkgconfig) - -add_executable(dummy src/dummy.cpp) -target_link_libraries(dummy PRIVATE aslp-lifter-gen) - -file(GLOB GENERATED include/aslp/generated/*.hpp) -set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED}") - -### aslp-lifter-llvm ### -# instantiates the aslp-lifter with a LLVM target - -# file(GLOB GEN_INSTANTIATE aslp-lifter-instantiate/*.cpp) -# add_library(aslp-lifter-llvm ${GEN_INSTANTIATE}) -# -# execute_process(COMMAND "${LLVM_CONFIG}" --libs support core irreader bitwriter -# COMMAND_ERROR_IS_FATAL ANY -# OUTPUT_VARIABLE llvm_libs OUTPUT_STRIP_TRAILING_WHITESPACE) -# message(STATUS "llvm_libs: ${llvm_libs}") -# separate_arguments(llvm_libs UNIX_COMMAND "${llvm_libs}") -# target_link_options(aslp-lifter-llvm BEFORE PUBLIC "${llvm_libs}") -# target_link_directories(aslp-lifter-llvm PUBLIC ${LLVM_LIBRARY_DIR}) -# target_include_directories(aslp-lifter-llvm PUBLIC ${LLVM_INCLUDE_DIRS}) -# -# target_link_libraries(aslp-lifter-llvm PUBLIC aslp-lifter-gen) -# -# target_compile_options(aslp-lifter-llvm PRIVATE "-includellvm_lifter_traits.hpp") -# target_compile_definitions(aslp-lifter-llvm PRIVATE "ASLP_LIFTER_INSTANTIATE=llvm_lifter_traits") -# -# -# ### aslp-lifter-bin ### -# # a simple test application -# add_executable(aslp-lifter-bin main.cpp) -# target_link_libraries(aslp-lifter-bin PUBLIC aslp-lifter-llvm) -# IF(CMAKE_BUILD_TYPE MATCHES DEBUG) -# target_compile_options(aslp-lifter-bin PRIVATE -g -Ofast -fsanitize=address) -# target_link_options(aslp-lifter-bin PRIVATE -g -Ofast -fsanitize=address) -# ENDIF() -# -# install(TARGETS aslp-lifter-bin DESTINATION bin) -# -# set_target_properties( -# aslp-lifter-bin -# PROPERTIES -# OUTPUT_NAME offlineasl -# RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin -# LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib -# ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib -# ) -# -# file(GLOB GENERATED aslp-lifter-gen/*.hpp aslp-lifter-instantiate/*.cpp) -# set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${GENERATED}") -# diff --git a/offlineASL-cpp/subprojects/aslp-lifter-gen/aslp-lifter-gen.pc.in b/offlineASL-cpp/subprojects/aslp-lifter-gen/aslp-lifter-gen.pc.in deleted file mode 100644 index 5866dd52..00000000 --- a/offlineASL-cpp/subprojects/aslp-lifter-gen/aslp-lifter-gen.pc.in +++ /dev/null @@ -1,12 +0,0 @@ -prefix="@CMAKE_INSTALL_PREFIX@" -includedir="@CMAKE_INSTALL_FULL_INCLUDEDIR@" - -Name: @PROJECT_NAME@ -Description: @CMAKE_PROJECT_DESCRIPTION@ -URL: @CMAKE_PROJECT_HOMEPAGE_URL@ -Version: @PROJECT_VERSION@ -# Requires: @pc_req_public@ -# Requires.private: @pc_req_private@ -Cflags: -I"${includedir}" -# Libs: -L"${libdir}" -l@target1@ -l@target2@ -# Libs.private: -L"${libdir}" -l@target1@ -l@target2@ @pc_libs_private@ diff --git a/offlineASL-cpp/subprojects/aslp-lifter-gen/meson.build b/offlineASL-cpp/subprojects/aslp-lifter-gen/meson.build deleted file mode 100644 index a12e44f1..00000000 --- a/offlineASL-cpp/subprojects/aslp-lifter-gen/meson.build +++ /dev/null @@ -1,14 +0,0 @@ -project('aslp-lifter-gen', 'cpp', - version : '0.1', - default_options : ['warning_level=3', 'cpp_std=c++20']) - -incdir = 'include' - -install_subdir(incdir, install_dir : get_option('includedir'), strip_directory : true) -dep = declare_dependency(include_directories : incdir) - -pkg = import('pkgconfig') -pkg.generate( - name: meson.project_name(), - description: 'offline asl lifter library (template headers)', - subdirs: 'aslp') diff --git a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_interface.hpp b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_interface.hpp index 49bb6c79..cfca7724 100644 --- a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_interface.hpp +++ b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_interface.hpp @@ -1,3 +1,4 @@ +#pragma once #include #include #include diff --git a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_lifter_traits.hpp b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_lifter_traits.hpp index 41c64db6..b84d1e5c 100644 --- a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_lifter_traits.hpp +++ b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/include/aslp/llvm_lifter_traits.hpp @@ -1,3 +1,4 @@ +#pragma once #include #include diff --git a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/meson.build b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/meson.build index b330ca44..0e117d37 100644 --- a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/meson.build +++ b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/meson.build @@ -2,31 +2,26 @@ project('aslp-lifter-instantiate', 'cpp', version : '0.1', default_options : [ 'warning_level=3', 'cpp_std=c++20' ]) +version = meson.project_version() llvm_dep = dependency('llvm') -gen_name = 'aslp-lifter-gen' -gen_proj = subproject(gen_name, version: meson.project_version()) -gen_dep = gen_proj.get_variable('dep') -# gen_pc = gen_proj.get_variable('pc') +lifter_name = 'aslp-lifter' +lifter_proj = subproject(lifter_name, version: version) +instantiate_dep = lifter_proj.get_variable('instantiate_dep') incdir = 'include' install_subdir(incdir, install_dir : get_option('includedir'), strip_directory : true) -find = run_command('find', 'src', '-name', '*.cpp', check : true) -srcfiles = find.stdout().strip().split('\n')[0] # XXX for meson testing - lib = library( - 'aslp-lifter-instantiate', - srcfiles, + meson.project_name(), + [], include_directories : incdir, - dependencies: [ llvm_dep, gen_dep ], + dependencies: [ llvm_dep, instantiate_dep ], cpp_args: [ - '-Wno-unused-parameter', '-includeaslp/llvm_lifter_traits.hpp', '-DASLP_LIFTER_INSTANTIATE=llvm_lifter_traits'], + cpp_pch: 'pch/cpp_pch.hpp', install : true) -dep = declare_dependency(link_with: lib, dependencies: gen_dep) - pkg = import('pkgconfig') -pkg.generate(lib, subdirs: 'aslp', requires: gen_name) +pkg.generate(lib, requires: lifter_name + '=' + version) diff --git a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/pch/cpp_pch.hpp b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/pch/cpp_pch.hpp new file mode 100644 index 00000000..2c78aed1 --- /dev/null +++ b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/pch/cpp_pch.hpp @@ -0,0 +1,7 @@ +#include +#include +#include +#include +#include +#include +#include diff --git a/offlineASL-cpp/subprojects/aslp-lifter-instantiate/src/cpp_pch.hpp b/offlineASL-cpp/subprojects/aslp-lifter-instantiate/src/cpp_pch.hpp new file mode 100644 index 00000000..e69de29b diff --git a/offlineASL-cpp/subprojects/aslp-lifter-gen/include/aslp/aslp_lifter.hpp b/offlineASL-cpp/subprojects/aslp-lifter/include/aslp/aslp_lifter.hpp similarity index 100% rename from offlineASL-cpp/subprojects/aslp-lifter-gen/include/aslp/aslp_lifter.hpp rename to offlineASL-cpp/subprojects/aslp-lifter/include/aslp/aslp_lifter.hpp diff --git a/offlineASL-cpp/subprojects/aslp-lifter-gen/include/aslp/aslp_lifter_impl.hpp b/offlineASL-cpp/subprojects/aslp-lifter/include/aslp/aslp_lifter_impl.hpp similarity index 100% rename from offlineASL-cpp/subprojects/aslp-lifter-gen/include/aslp/aslp_lifter_impl.hpp rename to offlineASL-cpp/subprojects/aslp-lifter/include/aslp/aslp_lifter_impl.hpp diff --git a/offlineASL-cpp/subprojects/aslp-lifter-gen/include/aslp/interface.hpp b/offlineASL-cpp/subprojects/aslp-lifter/include/aslp/interface.hpp similarity index 100% rename from offlineASL-cpp/subprojects/aslp-lifter-gen/include/aslp/interface.hpp rename to offlineASL-cpp/subprojects/aslp-lifter/include/aslp/interface.hpp diff --git a/offlineASL-cpp/subprojects/aslp-lifter/meson.build b/offlineASL-cpp/subprojects/aslp-lifter/meson.build new file mode 100644 index 00000000..80db20f3 --- /dev/null +++ b/offlineASL-cpp/subprojects/aslp-lifter/meson.build @@ -0,0 +1,25 @@ +project('aslp-lifter', 'cpp', + version : '0.1', + default_options : ['warning_level=3', 'cpp_std=c++20']) + +incdir = 'include' +srcdir = 'src' +install_srcdir = get_option('datadir') / 'aslp' + +install_subdir(incdir, install_dir : get_option('includedir'), strip_directory : true) +gen_dep = declare_dependency(include_directories : incdir) + +find = run_command('find', srcdir, '-name', '*.cpp', check : true) +srcfiles = files(find.stdout().strip().split('\n')) + +install_subdir(srcdir, install_dir: install_srcdir, strip_directory : true) +instantiate_dep = declare_dependency( + sources: srcfiles, + dependencies: gen_dep, + compile_args: ['-Wno-unused-parameter']) + +pkg = import('pkgconfig') +pkg.generate( + name: meson.project_name(), + description: 'offline aslp lifter library (template headers and explicit instantiation sources)', + variables: {'srcdir': '${prefix}' / install_srcdir}) diff --git a/offlineASL-cpp/subprojects/aslp-lifter-gen/src/dummy.cpp b/offlineASL-cpp/subprojects/aslp-lifter/src/dummy.cpp similarity index 100% rename from offlineASL-cpp/subprojects/aslp-lifter-gen/src/dummy.cpp rename to offlineASL-cpp/subprojects/aslp-lifter/src/dummy.cpp