x86sim 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. x86sim-0.1.0/.clang-format +77 -0
  2. x86sim-0.1.0/.githooks/pre-commit +40 -0
  3. x86sim-0.1.0/.github/workflows/bindings.yml +92 -0
  4. x86sim-0.1.0/.github/workflows/docs.yml +26 -0
  5. x86sim-0.1.0/.github/workflows/executable.yml +39 -0
  6. x86sim-0.1.0/.github/workflows/tests.yml +86 -0
  7. x86sim-0.1.0/.gitignore +34 -0
  8. x86sim-0.1.0/CMakeLists.txt +143 -0
  9. x86sim-0.1.0/CMakePresets.json +66 -0
  10. x86sim-0.1.0/COPYING +340 -0
  11. x86sim-0.1.0/GNUmakefile +61 -0
  12. x86sim-0.1.0/PKG-INFO +216 -0
  13. x86sim-0.1.0/README.md +131 -0
  14. x86sim-0.1.0/cmake/GitRevision.cmake +16 -0
  15. x86sim-0.1.0/include/x86sim/addrspace.hpp +143 -0
  16. x86sim-0.1.0/include/x86sim/logging.hpp +293 -0
  17. x86sim-0.1.0/include/x86sim/registerfile.hpp +219 -0
  18. x86sim-0.1.0/include/x86sim/x86sim.hpp +393 -0
  19. x86sim-0.1.0/include/x86sim-support/cpuid.hpp +12 -0
  20. x86sim-0.1.0/include/x86sim-support/syscall-linux-posix.hpp +107 -0
  21. x86sim-0.1.0/include/x86sim-support/syscall-linux.hpp +311 -0
  22. x86sim-0.1.0/pyproject.toml +65 -0
  23. x86sim-0.1.0/requirements.txt +3 -0
  24. x86sim-0.1.0/src/bindings/binding.cpp +829 -0
  25. x86sim-0.1.0/src/raspsim/config.cpp +348 -0
  26. x86sim-0.1.0/src/raspsim/config.h +113 -0
  27. x86sim-0.1.0/src/raspsim/raspsim.cpp +325 -0
  28. x86sim-0.1.0/src/x86sim/addrspace.cpp +304 -0
  29. x86sim-0.1.0/src/x86sim/branchpred.cpp +416 -0
  30. x86sim-0.1.0/src/x86sim/branchpred.h +94 -0
  31. x86sim-0.1.0/src/x86sim/dcache.cpp +907 -0
  32. x86sim-0.1.0/src/x86sim/dcache.h +806 -0
  33. x86sim-0.1.0/src/x86sim/decode-complex.cpp +1974 -0
  34. x86sim-0.1.0/src/x86sim/decode-core.cpp +2367 -0
  35. x86sim-0.1.0/src/x86sim/decode-fast.cpp +989 -0
  36. x86sim-0.1.0/src/x86sim/decode-sse.cpp +1465 -0
  37. x86sim-0.1.0/src/x86sim/decode-x87.cpp +1172 -0
  38. x86sim-0.1.0/src/x86sim/decode.h +651 -0
  39. x86sim-0.1.0/src/x86sim/globals.h +599 -0
  40. x86sim-0.1.0/src/x86sim/logic.h +1276 -0
  41. x86sim-0.1.0/src/x86sim/ooocore.cpp +2040 -0
  42. x86sim-0.1.0/src/x86sim/ooocore.h +2173 -0
  43. x86sim-0.1.0/src/x86sim/oooexec.cpp +2400 -0
  44. x86sim-0.1.0/src/x86sim/ooopipe.cpp +2189 -0
  45. x86sim-0.1.0/src/x86sim/ptlhwdef.cpp +589 -0
  46. x86sim-0.1.0/src/x86sim/ptlhwdef.h +1661 -0
  47. x86sim-0.1.0/src/x86sim/ptlsim-api.h +121 -0
  48. x86sim-0.1.0/src/x86sim/ptlsim.cpp +159 -0
  49. x86sim-0.1.0/src/x86sim/ptlsim.h +211 -0
  50. x86sim-0.1.0/src/x86sim/registerfile.cpp +43 -0
  51. x86sim-0.1.0/src/x86sim/registers.def +97 -0
  52. x86sim-0.1.0/src/x86sim/seqcore.cpp +1602 -0
  53. x86sim-0.1.0/src/x86sim/seqcore.h +108 -0
  54. x86sim-0.1.0/src/x86sim/stats.h +102 -0
  55. x86sim-0.1.0/src/x86sim/superstl.cpp +364 -0
  56. x86sim-0.1.0/src/x86sim/superstl.h +1176 -0
  57. x86sim-0.1.0/src/x86sim/typedefs.h +28 -0
  58. x86sim-0.1.0/src/x86sim/uopimpl.cpp +2211 -0
  59. x86sim-0.1.0/src/x86sim/x86sim.cpp +358 -0
  60. x86sim-0.1.0/src/x86sim-linux/x86sim-linux.cpp +504 -0
  61. x86sim-0.1.0/src/x86sim-support/cpuid.cpp +86 -0
  62. x86sim-0.1.0/src/x86sim-support/syscall-linux-detail.hpp +301 -0
  63. x86sim-0.1.0/src/x86sim-support/syscall-linux-posix.cpp +2276 -0
  64. x86sim-0.1.0/src/x86sim-support/syscall-linux.cpp +818 -0
  65. x86sim-0.1.0/testinp +10 -0
  66. x86sim-0.1.0/tools/clang-format.sh +48 -0
  67. x86sim-0.1.0/x86sim/README.md +204 -0
  68. x86sim-0.1.0/x86sim/__init__.py +3 -0
  69. x86sim-0.1.0/x86sim/__main__.py +65 -0
  70. x86sim-0.1.0/x86sim/elf.py +239 -0
  71. x86sim-0.1.0/x86sim/machine.py +86 -0
  72. x86sim-0.1.0/x86sim/machinetypes.py +154 -0
  73. x86sim-0.1.0/x86sim/simcompile.py +113 -0
@@ -0,0 +1,77 @@
1
+ ---
2
+ # clang-format configuration for RASPsim
3
+ BasedOnStyle: LLVM
4
+
5
+ # Basic formatting
6
+ IndentWidth: 2
7
+ TabWidth: 2
8
+ UseTab: Never
9
+ ColumnLimit: 120
10
+
11
+ # Language
12
+ Language: Cpp
13
+ Standard: c++20
14
+
15
+ # Braces
16
+ BreakBeforeBraces: Attach
17
+ BraceWrapping:
18
+ AfterClass: false
19
+ AfterControlStatement: Never
20
+ AfterEnum: false
21
+ AfterFunction: false
22
+ AfterNamespace: false
23
+ AfterStruct: false
24
+ AfterUnion: false
25
+ BeforeCatch: false
26
+ BeforeElse: false
27
+
28
+ # Indentation
29
+ NamespaceIndentation: None
30
+ IndentCaseLabels: false
31
+ IndentPPDirectives: None
32
+ AccessModifierOffset: -2
33
+
34
+ # Alignment
35
+ AlignAfterOpenBracket: Align
36
+ AlignConsecutiveAssignments: None
37
+ AlignConsecutiveDeclarations: None
38
+ AlignOperands: Align
39
+ AlignTrailingComments: true
40
+ PointerAlignment: Left
41
+
42
+ # Spacing
43
+ SpaceAfterCStyleCast: false
44
+ SpaceAfterTemplateKeyword: false
45
+ SpaceBeforeAssignmentOperators: true
46
+ SpaceBeforeParens: ControlStatements
47
+ SpaceInEmptyParentheses: false
48
+ SpacesInAngles: false
49
+ SpacesInCStyleCastParentheses: false
50
+ SpacesInContainerLiterals: false
51
+ SpacesInParentheses: false
52
+ SpacesInSquareBrackets: false
53
+
54
+ # Line breaks
55
+ AllowShortBlocksOnASingleLine: Empty
56
+ AllowShortCaseLabelsOnASingleLine: false
57
+ AllowShortFunctionsOnASingleLine: Inline
58
+ AllowShortIfStatementsOnASingleLine: Never
59
+ AllowShortLoopsOnASingleLine: false
60
+ AlwaysBreakAfterReturnType: None
61
+ AlwaysBreakBeforeMultilineStrings: false
62
+ AlwaysBreakTemplateDeclarations: Yes
63
+ BinPackArguments: true
64
+ BinPackParameters: true
65
+ BreakBeforeBinaryOperators: None
66
+ BreakBeforeTernaryOperators: true
67
+ BreakConstructorInitializers: BeforeColon
68
+ BreakInheritanceList: BeforeColon
69
+
70
+ # Includes
71
+ SortIncludes: false
72
+ IncludeBlocks: Preserve
73
+
74
+ # Other
75
+ KeepEmptyLinesAtTheStartOfBlocks: true
76
+ MaxEmptyLinesToKeep: 2
77
+ ReflowComments: false
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env sh
2
+ # Reject commits whose staged C/C++ changes are not clang-format clean.
3
+ #
4
+ # Enable with: git config core.hooksPath .githooks
5
+ # (run once per clone; `make hooks` does this for you).
6
+ #
7
+ # Set CLANG_FORMAT to override the binary. If clang-format is missing the hook
8
+ # skips silently rather than blocking the commit.
9
+ set -eu
10
+
11
+ CLANG_FORMAT="${CLANG_FORMAT:-clang-format}"
12
+ if ! command -v "$CLANG_FORMAT" >/dev/null 2>&1; then
13
+ echo "pre-commit: '$CLANG_FORMAT' not found; skipping clang-format check" >&2
14
+ exit 0
15
+ fi
16
+
17
+ # Added/copied/modified staged sources owned by this project.
18
+ files=$(git diff --cached --name-only --diff-filter=ACM -- \
19
+ 'src/*.cpp' 'src/*.cc' 'src/*.c' 'src/*.h' 'src/*.hpp' \
20
+ 'include/*.h' 'include/*.hpp' 'include/*.cpp')
21
+ [ -z "$files" ] && exit 0
22
+
23
+ fail=0
24
+ for f in $files; do
25
+ # Compare the *staged* blob against its formatted form, so what gets checked
26
+ # is exactly what would be committed (not unstaged working-tree edits).
27
+ staged=$(git show ":$f")
28
+ formatted=$(printf '%s' "$staged" | "$CLANG_FORMAT" --assume-filename="$f")
29
+ if [ "$staged" != "$formatted" ]; then
30
+ echo "pre-commit: needs formatting: $f" >&2
31
+ fail=1
32
+ fi
33
+ done
34
+
35
+ if [ "$fail" -ne 0 ]; then
36
+ echo "" >&2
37
+ echo "Fix with 'tools/clang-format.sh fix' (or clang-format -i), then re-stage." >&2
38
+ exit 1
39
+ fi
40
+ exit 0
@@ -0,0 +1,92 @@
1
+ name: Build Python Package
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+ release:
9
+ types: [ published ]
10
+
11
+ jobs:
12
+ sdist:
13
+ name: Build source distribution
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v5
17
+ with:
18
+ fetch-depth: 0 # GitRevision.cmake stamps the build from git
19
+
20
+ - uses: actions/setup-python@v6
21
+ with:
22
+ python-version: '3.x'
23
+
24
+ - name: Build sdist
25
+ run: |
26
+ python -m pip install --upgrade build
27
+ python -m build --sdist
28
+
29
+ - uses: actions/upload-artifact@v7
30
+ with:
31
+ name: dist-sdist
32
+ path: dist/*.tar.gz
33
+
34
+ wheels:
35
+ name: Build manylinux wheels
36
+ runs-on: ubuntu-latest
37
+ # A wheel-build hiccup (e.g. toolchain availability in the manylinux image)
38
+ # must never block publishing the sdist, which always installs from source.
39
+ continue-on-error: true
40
+ steps:
41
+ - uses: actions/checkout@v5
42
+ with:
43
+ fetch-depth: 0
44
+
45
+ - name: Build wheels
46
+ uses: pypa/cibuildwheel@v4.1.0
47
+ env:
48
+ # x86sim needs C++26 (std::expected). The default manylinux compiler
49
+ # is too old, so install a recent GCC toolset and point the build at
50
+ # it. Bump the toolset version if cxx_std_26 is rejected.
51
+ CIBW_BUILD: "cp310-* cp311-* cp312-* cp313-*"
52
+ CIBW_SKIP: "*-musllinux*"
53
+ CIBW_ARCHS_LINUX: "x86_64"
54
+ CIBW_MANYLINUX_X86_64_IMAGE: "manylinux_2_28"
55
+ CIBW_BEFORE_ALL_LINUX: "dnf install -y gcc-toolset-14-gcc-c++ || dnf install -y gcc-toolset-13-gcc-c++"
56
+ # CXXFLAGS silences -Winvalid-offsetof: several simulator structs use
57
+ # C-style layout idioms on non-standard-layout types, so offsetof is
58
+ # only conditionally-supported and the gcc-toolset warns at every site.
59
+ CIBW_ENVIRONMENT_LINUX: >-
60
+ PATH=/opt/rh/gcc-toolset-14/root/usr/bin:/opt/rh/gcc-toolset-13/root/usr/bin:$PATH
61
+ CXXFLAGS=-Wno-invalid-offsetof
62
+ CIBW_TEST_REQUIRES: "pyelftools"
63
+ CIBW_TEST_COMMAND: "python -c \"import x86sim; x86sim.Machine()\""
64
+
65
+ - uses: actions/upload-artifact@v7
66
+ with:
67
+ name: dist-wheels
68
+ path: wheelhouse/*.whl
69
+
70
+ publish-to-pypi:
71
+ name: Publish 🐍 distribution 📦 to PyPI
72
+ needs: [ sdist, wheels ]
73
+ # Only publish on a GitHub Release; pushes to main would collide on the
74
+ # already-uploaded version.
75
+ if: github.event_name == 'release'
76
+ runs-on: ubuntu-latest
77
+ environment:
78
+ name: pypi
79
+ url: https://pypi.org/p/x86sim
80
+ permissions:
81
+ id-token: write # required for PyPI Trusted Publishing (OIDC)
82
+
83
+ steps:
84
+ - name: Download all distributions
85
+ uses: actions/download-artifact@v8
86
+ with:
87
+ pattern: dist-*
88
+ merge-multiple: true
89
+ path: dist/
90
+
91
+ - name: Publish distribution 📦 to PyPI
92
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,26 @@
1
+ name: Build Documentation
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: self-hosted
12
+
13
+ steps:
14
+ - uses: actions/checkout@v5
15
+
16
+ - name: Build Docs
17
+ run: make -C Documentation
18
+
19
+
20
+ - name: Upload PTLsimManual
21
+ uses: actions/upload-artifact@v7
22
+ with:
23
+ name: PTLsimManual.pdf
24
+ path: Documentation/PTLsimManual.pdf
25
+
26
+
@@ -0,0 +1,39 @@
1
+ name: Build Executable
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+
13
+ # ubuntu-latest ships GCC 13, which does not accept -std=c++26. Install a
14
+ # C++26-capable toolchain (and Ninja, the default generator) and point the
15
+ # build at it.
16
+ env:
17
+ CC: gcc-14
18
+ CXX: g++-14
19
+ # Several simulator structs intentionally use C-style layout idioms on
20
+ # non-standard-layout types, so __builtin_offsetof (offsetof_/baseof) is
21
+ # only conditionally-supported and GCC warns at every site. Silence that
22
+ # category for the CI build only; CMake folds CXXFLAGS into the cache on
23
+ # the first (always fresh here) configure.
24
+ CXXFLAGS: -Wno-invalid-offsetof
25
+
26
+ steps:
27
+ - uses: actions/checkout@v5
28
+
29
+ - name: Install toolchain
30
+ run: sudo apt-get update && sudo apt-get install -y g++-14 ninja-build cmake
31
+
32
+ - name: Build raspsim Executable
33
+ run: make -j$(nproc) raspsim
34
+
35
+ - name: Upload raspsim Executable
36
+ uses: actions/upload-artifact@v7
37
+ with:
38
+ name: raspsim
39
+ path: raspsim
@@ -0,0 +1,86 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ "main" ]
6
+ pull_request:
7
+ branches: [ "main" ]
8
+
9
+ # These runs are long. Cancel superseded runs on the same ref so the
10
+ # self-hosted runners are not tied up by stale commits.
11
+ concurrency:
12
+ group: tests-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ jobs:
16
+ # ---------------------------------------------------------------------------
17
+ # Gate 0: style. Cheap, so it fails fast before any runner time is spent
18
+ # building or simulating.
19
+ # ---------------------------------------------------------------------------
20
+ format:
21
+ name: clang-format
22
+ runs-on: self-hosted
23
+ steps:
24
+ - uses: actions/checkout@v5
25
+ - name: Check formatting
26
+ run: tools/clang-format.sh check
27
+
28
+ # ---------------------------------------------------------------------------
29
+ # Gate 1: quick smoke per core (extraquick suite). Individual jobs so each
30
+ # core reports separately and can land on its own runner.
31
+ # ---------------------------------------------------------------------------
32
+ quick-seq:
33
+ name: Quick (seq)
34
+ needs: format
35
+ runs-on: self-hosted
36
+ steps:
37
+ - uses: actions/checkout@v5
38
+ - name: Configure
39
+ run: cmake --preset release -DCMAKE_CXX_FLAGS=-Wno-invalid-offsetof -DSQLITE_TEST_SUITE=extraquick -DSQLITE_TEST_CORES=seq
40
+ - name: Build
41
+ run: cmake --build --preset release --target x86sim-linux
42
+ - name: Test (seq, extraquick)
43
+ run: ctest --test-dir build/release -L seq --output-on-failure -j "$(nproc)"
44
+
45
+ quick-ooo:
46
+ name: Quick (ooo)
47
+ needs: format
48
+ runs-on: self-hosted
49
+ steps:
50
+ - uses: actions/checkout@v5
51
+ - name: Configure
52
+ run: cmake --preset release -DCMAKE_CXX_FLAGS=-Wno-invalid-offsetof -DSQLITE_TEST_SUITE=extraquick -DSQLITE_TEST_CORES=ooo
53
+ - name: Build
54
+ run: cmake --build --preset release --target x86sim-linux
55
+ - name: Test (ooo, extraquick)
56
+ run: ctest --test-dir build/release -L ooo --output-on-failure -j "$(nproc)"
57
+
58
+ # ---------------------------------------------------------------------------
59
+ # Gate 2: full suite per core. Only runs if BOTH quick jobs passed, so we
60
+ # never spend the (very long) full run on a build that fails the smoke test.
61
+ # ---------------------------------------------------------------------------
62
+ full-seq:
63
+ name: Full (seq)
64
+ needs: [quick-seq, quick-ooo]
65
+ runs-on: self-hosted
66
+ steps:
67
+ - uses: actions/checkout@v5
68
+ - name: Configure
69
+ run: cmake --preset release -DCMAKE_CXX_FLAGS=-Wno-invalid-offsetof -DSQLITE_TEST_SUITE=all -DSQLITE_TEST_CORES=seq
70
+ - name: Build
71
+ run: cmake --build --preset release --target x86sim-linux
72
+ - name: Test (seq, full)
73
+ run: ctest --test-dir build/release -L seq --output-on-failure -j "$(nproc)"
74
+
75
+ full-ooo:
76
+ name: Full (ooo)
77
+ needs: [quick-seq, quick-ooo]
78
+ runs-on: self-hosted
79
+ steps:
80
+ - uses: actions/checkout@v5
81
+ - name: Configure
82
+ run: cmake --preset release -DCMAKE_CXX_FLAGS=-Wno-invalid-offsetof -DSQLITE_TEST_SUITE=all -DSQLITE_TEST_CORES=ooo
83
+ - name: Build
84
+ run: cmake --build --preset release --target x86sim-linux
85
+ - name: Test (ooo, full)
86
+ run: ctest --test-dir build/release -L ooo --output-on-failure -j "$(nproc)"
@@ -0,0 +1,34 @@
1
+ .depend
2
+ cpuid
3
+ ptlsim.log*
4
+ dstbuild.temp.cpp
5
+ ptlsim
6
+ ptlsim.dst
7
+ ptlstats
8
+ ./raspsim
9
+ test.dat
10
+ dumpcode.dat
11
+ *.o
12
+ venv
13
+ __pycache__
14
+ *.so
15
+ *.pyi
16
+ *.egg-info
17
+ /dist
18
+ /build-wheel
19
+ .cache/
20
+ .DS_Store
21
+
22
+ CMakeFiles
23
+ CMakeCache.txt
24
+ cmake_install.cmake
25
+ *.ninja*
26
+ /raspsim
27
+ build/
28
+ compile_commands.json
29
+ Makefile
30
+ makefile
31
+
32
+ # Built example guests (assembled from the .S sources)
33
+ examples/linux-x86_64/echo
34
+ examples/linux-x86_64/hello_syscalls
@@ -0,0 +1,143 @@
1
+ cmake_minimum_required(VERSION 3.25)
2
+
3
+ project(x86sim
4
+ DESCRIPTION "Cycle-accurate x86-64 virtual CPU core and command-line simulators"
5
+ LANGUAGES CXX
6
+ )
7
+
8
+ option(X86SIM_BUILD_DEFAULTS "Build the Linux syscall/cpuid support library" ON)
9
+ option(X86SIM_BUILD_RASPSIM "Build the raspsim command-line simulator" ON)
10
+ option(X86SIM_BUILD_LINUX "Build the x86sim-linux command-line simulator" ON)
11
+ option(X86SIM_BUILD_TESTS "Build the CTest suite (SQLite through x86sim-linux)" ON)
12
+ option(X86SIM_BUILD_PYTHON "Build the pybind11 Python extension module" OFF)
13
+
14
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
15
+ include(GNUInstallDirs)
16
+ include(GitRevision)
17
+
18
+ # Build-time provenance, stamped into the core library and the simulators.
19
+ cmake_host_system_information(RESULT buildhost QUERY FQDN)
20
+ set(build_info BUILDHOST=${buildhost} GIT_REVISION=${GIT_REVISION})
21
+
22
+ set(install_targets)
23
+
24
+ # --- x86sim: portable virtual CPU core (always built) ---------------------
25
+ file(GLOB vcore_sources CONFIGURE_DEPENDS src/x86sim/*.cpp)
26
+ add_library(x86sim)
27
+ add_library(x86sim::x86sim ALIAS x86sim)
28
+ target_sources(x86sim
29
+ PRIVATE
30
+ ${vcore_sources}
31
+ PUBLIC
32
+ FILE_SET HEADERS
33
+ BASE_DIRS include
34
+ FILES
35
+ include/x86sim/logging.hpp
36
+ include/x86sim/registerfile.hpp
37
+ include/x86sim/x86sim.hpp
38
+ )
39
+ target_include_directories(x86sim PRIVATE src/x86sim)
40
+ target_compile_definitions(x86sim PRIVATE ${build_info})
41
+ target_compile_features(x86sim PUBLIC cxx_std_26)
42
+ # The Python module links this static archive into a shared object, so it must
43
+ # be position-independent. Scoped to the wheel build to keep the executables
44
+ # non-PIC.
45
+ set_target_properties(x86sim PROPERTIES POSITION_INDEPENDENT_CODE ${X86SIM_BUILD_PYTHON})
46
+ list(APPEND install_targets x86sim)
47
+
48
+ # --- x86sim_defaults: Linux syscall + cpuid support library ---------------
49
+ if(X86SIM_BUILD_DEFAULTS)
50
+ add_library(x86sim_defaults)
51
+ add_library(x86sim::defaults ALIAS x86sim_defaults)
52
+ set_target_properties(x86sim_defaults PROPERTIES EXPORT_NAME defaults)
53
+ target_sources(x86sim_defaults
54
+ PRIVATE
55
+ src/x86sim-support/cpuid.cpp
56
+ src/x86sim-support/syscall-linux.cpp
57
+ PUBLIC
58
+ FILE_SET HEADERS
59
+ BASE_DIRS include
60
+ FILES
61
+ include/x86sim-support/cpuid.hpp
62
+ include/x86sim-support/syscall-linux.hpp
63
+ )
64
+ target_link_libraries(x86sim_defaults PUBLIC x86sim::x86sim)
65
+ target_include_directories(x86sim_defaults PRIVATE src/x86sim)
66
+ set_target_properties(x86sim_defaults PROPERTIES POSITION_INDEPENDENT_CODE ${X86SIM_BUILD_PYTHON})
67
+ list(APPEND install_targets x86sim_defaults)
68
+ endif()
69
+
70
+ # --- x86sim_posix: host-POSIX Linux syscall handlers ----------------------
71
+ # File/socket/host-time handlers split out of x86sim_defaults so the defaults
72
+ # library stays fully portable (no host headers). Only the native x86sim-linux
73
+ # tool links it; raspsim and the Python wheel keep linking x86sim::defaults.
74
+ if(X86SIM_BUILD_LINUX)
75
+ add_library(x86sim_posix)
76
+ add_library(x86sim::posix ALIAS x86sim_posix)
77
+ set_target_properties(x86sim_posix PROPERTIES EXPORT_NAME posix)
78
+ target_sources(x86sim_posix
79
+ PRIVATE
80
+ src/x86sim-support/syscall-linux-posix.cpp
81
+ PUBLIC
82
+ FILE_SET HEADERS
83
+ BASE_DIRS include
84
+ FILES
85
+ include/x86sim-support/syscall-linux-posix.hpp
86
+ )
87
+ target_link_libraries(x86sim_posix PUBLIC x86sim::defaults)
88
+ target_include_directories(x86sim_posix PRIVATE src/x86sim)
89
+ list(APPEND install_targets x86sim_posix)
90
+ endif()
91
+
92
+ # --- raspsim: command-line simulator --------------------------------------
93
+ if(X86SIM_BUILD_RASPSIM)
94
+ add_executable(raspsim
95
+ src/raspsim/config.cpp
96
+ src/raspsim/raspsim.cpp
97
+ )
98
+ target_link_libraries(raspsim PRIVATE x86sim::defaults)
99
+ target_include_directories(raspsim PRIVATE src/x86sim)
100
+ list(APPEND install_targets raspsim)
101
+ endif()
102
+
103
+ # --- x86sim-linux: command-line simulator ---------------------------------
104
+ if(X86SIM_BUILD_LINUX)
105
+ add_executable(x86sim-linux
106
+ src/x86sim-linux/x86sim-linux.cpp
107
+ )
108
+ target_link_libraries(x86sim-linux PRIVATE x86sim::posix)
109
+ list(APPEND install_targets x86sim-linux)
110
+ endif()
111
+
112
+ # --- install / export -----------------------------------------------------
113
+ install(TARGETS ${install_targets}
114
+ EXPORT x86simTargets
115
+ FILE_SET HEADERS
116
+ )
117
+ install(EXPORT x86simTargets
118
+ NAMESPACE x86sim::
119
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/x86sim"
120
+ )
121
+
122
+ # --- python bindings ------------------------------------------------------
123
+ # The extension links the portable support library (x86sim::defaults) for the
124
+ # cpuid defaults and the portable Linux heap (brk/mmap) + ABI helpers. It never
125
+ # links x86sim::posix, so the wheel stays buildable off-Linux. Driven by
126
+ # pyproject.toml, which points scikit-build-core at this file, forces
127
+ # X86SIM_BUILD_DEFAULTS=ON, and disables the Linux tools. (The wasm binding is a
128
+ # separate target.)
129
+ if(X86SIM_BUILD_PYTHON)
130
+ find_package(pybind11 CONFIG REQUIRED)
131
+ pybind11_add_module(bindings MODULE
132
+ src/bindings/binding.cpp
133
+ )
134
+ target_link_libraries(bindings PRIVATE x86sim::defaults)
135
+ target_include_directories(bindings PRIVATE include)
136
+ install(TARGETS bindings LIBRARY DESTINATION x86sim)
137
+ endif()
138
+
139
+ # --- tests ----------------------------------------------------------------
140
+ if(X86SIM_BUILD_TESTS)
141
+ enable_testing()
142
+ add_subdirectory(tests/sqlite3)
143
+ endif()
@@ -0,0 +1,66 @@
1
+ {
2
+ "version": 6,
3
+ "cmakeMinimumRequired": { "major": 3, "minor": 25, "patch": 0 },
4
+ "configurePresets": [
5
+ {
6
+ "name": "base",
7
+ "hidden": true,
8
+ "binaryDir": "${sourceDir}/build/${presetName}",
9
+ "cacheVariables": {
10
+ "CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
11
+ "CMAKE_CXX_STANDARD": "26",
12
+ "CMAKE_CXX_STANDARD_REQUIRED": "ON",
13
+ "CMAKE_CXX_EXTENSIONS": "OFF"
14
+ }
15
+ },
16
+ {
17
+ "name": "debug",
18
+ "inherits": "base",
19
+ "displayName": "Debug",
20
+ "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" }
21
+ },
22
+ {
23
+ "name": "release",
24
+ "inherits": "base",
25
+ "displayName": "Release",
26
+ "cacheVariables": { "CMAKE_BUILD_TYPE": "Release" }
27
+ },
28
+ {
29
+ "name": "relwithdeb",
30
+ "inherits": "base",
31
+ "displayName": "RelWithDebInfo",
32
+ "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo" }
33
+ },
34
+ {
35
+ "name": "tsan",
36
+ "inherits": "base",
37
+ "displayName": "ThreadSanitizer",
38
+ "cacheVariables": {
39
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo",
40
+ "CMAKE_CXX_FLAGS": "-fsanitize=thread -g -O1 -fno-omit-frame-pointer",
41
+ "CMAKE_EXE_LINKER_FLAGS": "-fsanitize=thread"
42
+ }
43
+ }
44
+ ],
45
+ "buildPresets": [
46
+ { "name": "debug", "configurePreset": "debug" },
47
+ { "name": "release", "configurePreset": "release" },
48
+ { "name": "relwithdeb", "configurePreset": "relwithdeb" },
49
+ { "name": "tsan", "configurePreset": "tsan" }
50
+ ],
51
+ "testPresets": [
52
+ {
53
+ "name": "debug",
54
+ "configurePreset": "debug",
55
+ "output": { "outputOnFailure": true }
56
+ },
57
+ {
58
+ "name": "tsan",
59
+ "configurePreset": "tsan",
60
+ "output": { "outputOnFailure": true },
61
+ "environment": {
62
+ "TSAN_OPTIONS": "halt_on_error=1"
63
+ }
64
+ }
65
+ ]
66
+ }