<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/132792>132792</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Re-exporting a module in a modulemap does not seem to work
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          Steelskin
      </td>
    </tr>
</table>

<pre>
    ### 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](https://clang.llvm.org/docs/Modules.html#export-declaration) 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
}
```

```c++
// interop.h
# pragma once

int g_property = 0;
```

Build commands:
```bash
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:

1. `strings` does not find `g_property` in `Interop.pcm`
```bash
$ strings Container.pcm | grep g_property
$ string Interop.pcm | grep g_property

g_property
```

2. `clang -module-file-info` does not list `interop.h` for `Container.pcm`
```bash
$ 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
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsVkuP2zYQ_jX0ZWBDpuTXwQfvOkb3kCJI2kNPBUWOJDYUKZDUOv73xUi0LW-aRQv00EMBA4bAmW8e37xECLq2iHu2emKr40z0sXF-_yUimvBV21np1GXPeD7-4EvftsJfWHZg2eHZ2aAVeogNQuWMcWdta2id6g22ooNKG2Q5ibJ1ln7ZYXyHFxvRuw7Y5ollBwCABgWhMc71-LZoGOfpEb91zkdgfIDbHEcXEtazs1FoS8o3tKSQzNyVJp6w7PACZ9cbRdIoI8RGROgDhUFBsXV2g2brLIWWVOT4AsIYcNUgr7DSVkftbIDKu_YKcnXiBsH4M4gwPq-elJN9izYK0mSrI-PbJsYuUO74ifGTNMLWC2Ne24XzNeMn5WRg_PRxAAuLJraG8XwMea5QGuFHML6DgNgGiA60VVqKeKUk_wAHC9_rQOhQ6kpjgHOjZQO6JRFUyfcAZ20MiD66VkQthTEXKBE8zkcwVBRbJ3ykvAio9Svaa-AfONtmbLcLcPj0shhJ-Mmd8RU9JeUFGvFK1dRbNbIRGx1AOQxgXYSz818JfeQLVUK4V-hn7LyDELEL6WlK-JDN5MriVqj_taK8fUrGn-h38_zuwxAzdF7UrQBnJY6q2kaof--869DHC7D8CBnLn7638dTroYbbVlgV3nRpKQJZGMoO5lIuYY6tjvMU2dzdg1t0soV5dS2Nt6m9Pc2taJHlx3s_vYufMvRP0SeJfdvncmhaqqFK171HEBZQhAucxYW6o8Y49GO4tKUzAVwfr2396fkj1WbZR3gBKSxoW6WxZ4T8SmJsnd3TTn0-woC27w0SbYGT_Wv-s8NyQbIhem3rQJK3yq-0Vd-b0XYyXyhbKeI3TDJeQAJ9Qx3bPEPtsZtUzYP8AxM_EM4Oj9-PqedDSInrRBdthrm2lXsI0egQSfZe5esMKucf0vd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