Skip to content

Conversation

@LawrenceHunter
Copy link
Contributor

@LawrenceHunter LawrenceHunter commented Jul 22, 2025

Fixes an error when running a 32 bit version of SoftHSM where readdir fails with errno 75.

Summary by CodeRabbit

  • Chores
    • Improved large file support by enabling 64-bit file offsets for both C and C++ builds.

@LawrenceHunter LawrenceHunter requested a review from a team as a code owner July 22, 2025 10:07
@coderabbitai
Copy link

coderabbitai bot commented Jul 22, 2025

Walkthrough

The changes add the compiler flag -D_FILE_OFFSET_BITS=64 to both C and C++ compilation processes in the project's build configuration files. This ensures large file support is enabled by default during compilation. No other logic or exported entities are altered.

Changes

File(s) Change Summary
configure.ac Appended -D_FILE_OFFSET_BITS=64 to CFLAGS and CXXFLAGS for large file support.
cmake/modules/CompilerOptions.cmake Added -D_FILE_OFFSET_BITS=64 to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS for large file support.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐇
Flags unfurled for files so large,
Now offsets stretch—no need to charge!
With sixty-four, we leap ahead,
In C and C++, well-fed.
Compile with cheer, the bytes won’t bite—
Our code now handles files just right!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@kalvdans
Copy link

Just unconditionally enable it, there's no reason to use 32-bit file offsets even on 32-bit systems.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
m4/acx_64bit_file_offset.m4 (1)

4-4: Use consistent naming convention for the configure option.

The help string uses --enable_64bit_file_offset with underscores, but Autoconf configure options typically use hyphens. Consider using --enable-64bit-file-offset for consistency with standard conventions.

-		[AS_HELP_STRING([--enable_64bit_file_offset],[enable 64 bit file offset mode @<:@enabled@:>@])],
+		[AS_HELP_STRING([--enable-64bit-file-offset],[enable 64 bit file offset mode @<:@enabled@:>@])],

Note: If you make this change, also update the variable name from enable_64bit_file_offset to enable_64bit_file_offset (Autoconf automatically converts hyphens to underscores in variable names).

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 557b2fd and b24c880.

📒 Files selected for processing (2)
  • configure.ac (1 hunks)
  • m4/acx_64bit_file_offset.m4 (1 hunks)
🔇 Additional comments (2)
m4/acx_64bit_file_offset.m4 (1)

9-10: LGTM: Correct implementation of 64-bit file offset support.

The macro correctly appends -D_FILE_OFFSET_BITS=64 to both C and C++ compiler flags, which is the standard approach for enabling large file support on systems that require it.

configure.ac (1)

53-53: LGTM: Proper integration of the new macro.

The macro is correctly invoked in the appropriate section alongside other compiler flag configuration macros. The placement after ACX_64BIT is logical and maintains good organization.

Note: Ensure that if the macro parameter name is corrected in m4/acx_64bit_file_offset.m4 (changing "strict" to "64bit_file_offset"), this invocation will continue to work correctly.

@LawrenceHunter LawrenceHunter force-pushed the lawrence/64bit_file_offset branch from b24c880 to 92ba5c3 Compare July 22, 2025 10:16
@LawrenceHunter
Copy link
Contributor Author

Just unconditionally enable it, there's no reason to use 32-bit file offsets even on 32-bit systems.

Okay I'll set it enabled by default

@LawrenceHunter LawrenceHunter force-pushed the lawrence/64bit_file_offset branch from 92ba5c3 to 29d0650 Compare July 22, 2025 10:18
@kalvdans
Copy link

Just unconditionally enable it, there's no reason to use 32-bit file offsets even on 32-bit systems.

Okay I'll set it enabled by default

No, don't even make it configurable. Hardcode it in CFLAGS.

@LawrenceHunter
Copy link
Contributor Author

Just unconditionally enable it, there's no reason to use 32-bit file offsets even on 32-bit systems.

Okay I'll set it enabled by default

No, don't even make it configurable. Hardcode it in CFLAGS.

I can't see a place where this would be suitable to add as they're all under the *.m4 files the current implementation makes it the same as strict

@kalvdans
Copy link

I'm not fluent in autotools but I guess it would go into Makefile.am in some form. Also it needs to go into CMakeLists.txt for people using cmake.

@jschlyter jschlyter requested a review from bjosv July 22, 2025 18:17
Copy link
Contributor

@bjosv bjosv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.
Either remove the AC_ARG_ENABLE part, or just add the flags in configure.ac directly, like:

# Compiler flags
CFLAGS="${CFLAGS} -D_FILE_OFFSET_BITS=64"
CXXFLAGS="${CXXFLAGS} -D_FILE_OFFSET_BITS=64"
ACX_PEDANTIC
ACX_STRICT
ACX_64BIT
AX_CXX_COMPILE_STDCXX_11([noext],[optional])

A similar change for CMake should fit in cmake/modules/CompilerOptions.cmake.

@LawrenceHunter LawrenceHunter force-pushed the lawrence/64bit_file_offset branch from 29d0650 to c8de1f2 Compare July 25, 2025 10:22
@LawrenceHunter
Copy link
Contributor Author

Thanks for the advice both, it is now included in the flags.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
cmake/modules/CompilerOptions.cmake (1)

57-58: LGTM! Consider using modern CMake syntax for better maintainability.

The change correctly enables 64-bit file offsets to resolve the 32-bit readdir issue. However, consider using the more idiomatic CMake approach:

-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_FILE_OFFSET_BITS=64")
+add_compile_definitions(_FILE_OFFSET_BITS=64)

This approach is cleaner, more maintainable, and automatically handles the definition for all languages without string manipulation.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29d0650 and c8de1f2.

📒 Files selected for processing (2)
  • cmake/modules/CompilerOptions.cmake (1 hunks)
  • configure.ac (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • configure.ac

@LawrenceHunter LawrenceHunter changed the title Add optional enable_64bit_file_offset Add -D_FILE_OFFSET_BITS=64 Jul 25, 2025
@jschlyter jschlyter merged commit ebf6ff7 into softhsm:develop Jul 25, 2025
6 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants