Skip to content

Commit a390588

Browse files
committed
Allow compilation of 32-bit on 64-bit machines
1 parent fd003bf commit a390588

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ endif ()
2222
# Flags that are NOT expected to be shared when added as sub-directory
2323
# ------------------------------------------------------------------------
2424

25+
option (pfs_BUILD_32BIT "Build a 32-bit executable" OFF)
2526
option (pfs_BUILD_COVERAGE "Enable coverage instrumentation" OFF)
2627
option (pfs_BUILD_ASAN "Enable address sanitizer" OFF)
2728
option (pfs_BUILD_SAMPLES "Build samples" ON)
@@ -49,6 +50,11 @@ target_include_directories(
4950
$<INSTALL_INTERFACE:include>
5051
)
5152

53+
if (pfs_BUILD_32BIT)
54+
set (pfs_BUILD_32BIT_FLAGS -m32)
55+
target_compile_options (pfs PUBLIC ${pfs_BUILD_32BIT_FLAGS})
56+
endif ()
57+
5258
if (pfs_BUILD_COVERAGE)
5359
set (pfs_BUILD_COVERAGE_FLAGS -O0 --coverage)
5460
target_compile_options (pfs PUBLIC ${pfs_BUILD_COVERAGE_FLAGS})

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ Run `cmake . && make`
1414
### Currently supported CMake configuration flags:
1515

1616
- `CMAKE_BUILD_TYPE=<Debug|Release>`: Standard CMake flags to control build type (DEFAULT: Debug)
17+
- `pfs_BUILD_32BIT=<ON|OFF>`: ON to compile a 32-bit binary. OFF to compile using the default configuration of your compiler (DEFAULT: `OFF`))
18+
- You will need the `g++-multilib` package.
1719
- `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))
1820
- `pfs_BUILD_ASAN=<ON|OFF>`: ON to enable address sanitizer (DEFAULT: `OFF`)
1921
- `pfs_BUILD_SAMPLES=<ON|OFF>`: ON to build the sample programs (DEFAULT: `ON`)

docker/Dockerfile-debian12

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM debian:bookworm
1+
FROM i386/debian:bookworm
22

33
WORKDIR /pfs
44

src/mem.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ std::vector<uint8_t> mem::read(loff_t offset, size_t bytes)
5151

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

54-
ssize_t bytes_read = preadv64(_fd, &iov, 1, offset);
54+
ssize_t bytes_read = preadv(_fd, &iov, 1, offset);
5555
if (bytes_read == -1)
5656
{
5757
throw std::system_error(errno, std::system_category(),

0 commit comments

Comments
 (0)