Skip to content

Commit

Permalink
Allow compilation of 32-bit on 64-bit machines
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrugman committed May 16, 2024
1 parent fd003bf commit a390588
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ endif ()
# Flags that are NOT expected to be shared when added as sub-directory
# ------------------------------------------------------------------------

option (pfs_BUILD_32BIT "Build a 32-bit executable" OFF)
option (pfs_BUILD_COVERAGE "Enable coverage instrumentation" OFF)
option (pfs_BUILD_ASAN "Enable address sanitizer" OFF)
option (pfs_BUILD_SAMPLES "Build samples" ON)
Expand Down Expand Up @@ -49,6 +50,11 @@ target_include_directories(
$<INSTALL_INTERFACE:include>
)

if (pfs_BUILD_32BIT)
set (pfs_BUILD_32BIT_FLAGS -m32)
target_compile_options (pfs PUBLIC ${pfs_BUILD_32BIT_FLAGS})
endif ()

if (pfs_BUILD_COVERAGE)
set (pfs_BUILD_COVERAGE_FLAGS -O0 --coverage)
target_compile_options (pfs PUBLIC ${pfs_BUILD_COVERAGE_FLAGS})
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ Run `cmake . && make`
### Currently supported CMake configuration flags:

- `CMAKE_BUILD_TYPE=<Debug|Release>`: Standard CMake flags to control build type (DEFAULT: Debug)
- `pfs_BUILD_32BIT=<ON|OFF>`: ON to compile a 32-bit binary. OFF to compile using the default configuration of your compiler (DEFAULT: `OFF`))
- You will need the `g++-multilib` package.
- `pfs_BUILD_SHARED_LIBS=<ON|OFF>`: ON to compile a shared library. OFF to compile a static library (DEFAULT: Inherit `BUILD_SHARE_LIBS`, which is `OFF` by default))
- `pfs_BUILD_ASAN=<ON|OFF>`: ON to enable address sanitizer (DEFAULT: `OFF`)
- `pfs_BUILD_SAMPLES=<ON|OFF>`: ON to build the sample programs (DEFAULT: `ON`)
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile-debian12
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM debian:bookworm
FROM i386/debian:bookworm

WORKDIR /pfs

Expand Down
2 changes: 1 addition & 1 deletion src/mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ std::vector<uint8_t> mem::read(loff_t offset, size_t bytes)

struct iovec iov = {&buffer[0], buffer.size()};

ssize_t bytes_read = preadv64(_fd, &iov, 1, offset);
ssize_t bytes_read = preadv(_fd, &iov, 1, offset);
if (bytes_read == -1)
{
throw std::system_error(errno, std::system_category(),
Expand Down

0 comments on commit a390588

Please sign in to comment.