Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Module Map File #2953

Merged
merged 2 commits into from
Jan 6, 2022
Merged

Conversation

felixhandte
Copy link
Contributor

Internal discussion raised the question of how compatible zstd's headers are with C++ Modules, given that we use configuration macros to control what is exposed by zstd.h. This is a valid topic that is probably worth further discussion. It may be that the right approach is to expose a second libzstd-static module that exports the static definitions.

For the time being though, this PR makes several changes that seem worthwhile:

  1. It adds modules for the dictionary builder and errors headers.
  2. It captures all of the macros that are used to configure these headers. When the headers are imported as modules and one of these macros is defined the compiler issues a warning that it needs to be defined on the CLI. E.g.:
warning: definition of configuration macro 'ZSTD_STATIC_LINKING_ONLY' has no effect on the import of 'libzstd'; pass '-DZSTD_STATIC_LINKING_ONLY=...' on the command line to configure the module [-Wconfig-macros]
  1. It promotes the module.modulemap file into the root of the lib directory. Experimentation shows that clang's -fimplicit-module-maps will find the module map when placed here, but not when it's put in a subdirectory.

I know the module map was initially added in #2858. I don't have the capability to test whether these changes are compatible. Ideally @cntrump could weigh in.

To-do: create tests that can be added to validate that zstd remains compatible with modules. This is complicated by the fact that support is still experimental and present in only the most recent compilers.

@cntrump
Copy link
Contributor

cntrump commented Dec 24, 2021

Tested with GitHub workflow, https://github.com/cntrump/SwiftZST_Test

This commit makes several changes:

1. It adds modules for the dictionary builder and errors headers.
2. It captures all of the macros that are used to configure these headers.
   When the headers are imported as modules and one of these macros is defined
   the compiler issues a warning that it needs to be defined on the CLI.
3. It promotes the modulemap file into the root of the lib directory.
   Experimentation shows that clang's `-fimplicit-module-maps` will find the
   modulemap when placed here, but not when it's put in a subdirectory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants