[Pitch] Standard name for common low level C interfaces

The only way I can possibly see for a SystemC module to support both defining and not defining _GNU_SOURCE symbols is to have _GNU_SOURCE be locked behind a trait. I don't know how viable that is.

You may have meant this, but FWIW this requirement is not specific to explicit modules builds, it's just true of Swift dependency graphs in general. Implicit module builds were more likely to be unsound because they weren't always consistent about the precompiled Clang modules that were used as inputs to the build, but regardless of whether the build uses implicit or explicit modules, Swift only ever expects there to be exactly one variant of a Clang module used by all dependencies.

3 Likes

Right, exactly. Implicit module builds can get away with it because the implicit module caches will be separate and as long as you don't have two fundamentally different definitions of some C type getting imported into the same module, the problem might just be silently ignored (and indeed, that's what's happening for a lot of projects that do enable _GNU_SOURCE today).

On the other hand, at least in our Bazel builds with explicit modules, Clang will just hard-error immediately saying that the invocations don't match and refuse to load the AST file. I'm not sure how Swift's deps scanner operates here, though.

3 Likes

What I'm really trying to say is that I'm not proposing a behavior change with the existing platform modules - what they currently expose would remain the same. e.g. on macOS, __DARWIN_C_LEVEL defaults to __DARWIN_C_FULL so clients see all the POSIX/Darwin extensions by default. Importing SystemC would thus give you everything by default, same as if you #include the headers.

What I'm not proposing is some kind of mechanism whereby importing SystemC into Swift could specify a different __DARWIN_C_LEVEL in the module map or in the Swift overlay. Clients can choose a different level by passing something like -Xcc -D_ANSI_SOURCE, but by itself the module builds the same defaults as the headers themselves.

1 Like