Open
Description
Summary
Consider the following modulemap file:
module Interop {
header "interop.h"
export *
}
module Container {
export Interop
}
I would expect that using the Container
module would contain all of the definitions from the Interop
module, as the documentation seems to indicate:
An export-declaration specifies which imported modules will automatically be re-exported as part of a given module’s API.
However, I have found that this does not work as expected.
Repro steps
// module.modulemap
module Interop {
header "interop.h"
export *
}
module Container {
export Interop
}
// interop.h
# pragma once
int g_property = 0;
Build commands:
clang -cc1 -emit-module -o Container.pcm -fmodules module.modulemap -fmodule-name=Container
clang -cc1 -emit-module -o Interop.pcm -fmodules module.modulemap -fmodule-name=Interop
I could not figure an easy way to get the symbols out of the PCM, but I can infer the lack of g_property
symbol in the Container
module in 2 ways:
strings
does not findg_property
inInterop.pcm
$ strings Container.pcm | grep g_property
$ string Interop.pcm | grep g_property
g_property
clang -module-file-info
does not listinterop.h
forContainer.pcm
$ clang -module-file-info Container.pcm
[...]
Use libc++ (rather than libstdc++) [-stdlib=]: No
Preprocessor options:
Uses compiler/target-specific predefines [-undef]: Yes
Uses detailed preprocessing record (for indexing): No
Predefined macros:
Input file: [..]/module.modulemap
Diagnostic options:
[...]
$ clang -module-file-info Interop.pcm
[...]
Use libc++ (rather than libstdc++) [-stdlib=]: No
Preprocessor options:
Uses compiler/target-specific predefines [-undef]: Yes
Uses detailed preprocessing record (for indexing): No
Predefined macros:
Input file: [..]/module.modulemap
Input file: [..]/interop.h
Diagnostic options:
[...]
Related issue
This is problematic when using modulemaps with Swift, see swiftlang/swift#80216