Commit Graph

17 Commits

Author SHA1 Message Date
Ian Anderson
94e860e795 [ClangImporter] Swift needs to pass -Xclang -fbuiltin-headers-in-system-modules for its module maps that group cstd headers
Swift has some module maps it overlays on Linux and Windows that groups all of the C standard library headers into a single module. This doesn’t allow clang and C++ headers to layer properly with the OS/SDK modules. clang will set -fbuiltin-headers-in-system-modules as necessary for Apple SDKs, but Swift will need to pass that flag itself when required by its module maps.
2023-12-08 22:33:12 -08:00
Yuta Saito
643c7c8b49 [wasm][ClangImporter] Support wasi-libc.modulemap import with VFS 2023-09-23 11:52:31 +00:00
Saleem Abdulrasool
eee9331d97 ClangImporter: correct a duplicated path component
When computing the path for a non-architecture specific resource, we
would append the architecture unconditionally if `-sdk` is used.  This
would result in the path being miscomputed with the architecture or the
architecture duplicated if it was architecture specific.

Found by inspection.
2023-08-03 10:58:39 -07:00
Alex Lorenz
c215abdd8c [cxx-interop][linux] modularize the bits part of libstdc++
Fixes https://github.com/apple/swift/issues/64457
2023-07-27 10:20:28 -07:00
Evan Wilde
f3ff561c6f [NFC] add llvm namespace to Optional and None
This is phase-1 of switching from llvm::Optional to std::optional in the
next rebranch. llvm::Optional was removed from upstream LLVM, so we need
to migrate off rather soon. On Darwin, std::optional, and llvm::Optional
have the same layout, so we don't need to be as concerned about ABI
beyond the name mangling. `llvm::Optional` is only returned from one
function in
```
getStandardTypeSubst(StringRef TypeName,
                     bool allowConcurrencyManglings);
```
It's the return value, so it should not impact the mangling of the
function, and the layout is the same as `std::optional`, so it should be
mostly okay. This function doesn't appear to have users, and the ABI was
already broken 2 years ago for concurrency and no one seemed to notice
so this should be "okay".

I'm doing the migration incrementally so that folks working on main can
cherry-pick back to the release/5.9 branch. Once 5.9 is done and locked
away, then we can go through and finish the replacement. Since `None`
and `Optional` show up in contexts where they are not `llvm::None` and
`llvm::Optional`, I'm preparing the work now by going through and
removing the namespace unwrapping and making the `llvm` namespace
explicit. This should make it fairly mechanical to go through and
replace llvm::Optional with std::optional, and llvm::None with
std::nullopt. It's also a change that can be brought onto the
release/5.9 with minimal impact. This should be an NFC change.
2023-06-27 09:03:52 -07:00
Egor Zhdan
3e28a7c525 [cxx-interop] Make libstdc++ header and modulemap arch-independent
This moves `libstdcxx.modulemap` and `libstdcxx.h` from `*.xctoolchain/usr/lib/swift/macosx/arm64e` to `*.xctoolchain/usr/lib/swift/macosx` to simplify distribution.

rdar://110788977
2023-06-22 22:03:57 +01:00
Egor Zhdan
4ce4527ef1 [cxx-interop] Make CxxShim header and modulemap arch-independent
This moves `libcxxshim.modulemap`, `libcxxshim.h` and `libcxxstdlibshim.h` from `*.xctoolchain/usr/lib/swift/macosx/arm64e` to `*.xctoolchain/usr/lib/swift/macosx` to simplify distribution.

rdar://110788977
2023-06-20 15:57:38 +01:00
Alex Lorenz
11e5fc80b8 Merge pull request #64177 from hyp/eng/libstdcxx-dynamic
[interop] Configure libstdc++ module map at runtime
2023-03-08 15:34:51 -08:00
Alex Lorenz
eba8a00673 [interop] Inject header files into libstdcxx.modulemap dynamically
This allows the module map we use for libstdc++ to correctly include optional headers like "any" and other C++17/20 files.
2023-03-08 07:59:52 -08:00
Saleem Abdulrasool
73cafebaf5 Driver: introduce additional Windows controls
This adds the following four new options:
  - `-windows-sdk-root`
  - `-windows-sdk-version`
  - `-visualc-tools-root`
  - `-visualc-tools-version`

Together these options make one the master of Windows SDK selection for
the Swift compilation.  This is important as now that the injection is
no longer done by the user, we need to ensure that we have enough
control over the paths so that the synthesized overlay is going to map
the files to the proper location.
2023-03-06 13:29:31 -08:00
Saleem Abdulrasool
67d5deb110 ClangImporter: inject modulemaps via the VFS
This is the second step towards removal of the content injection into
the Visual Studio installation.  With this the new path is enabled to
create the mappings to the SDK shared content.  Subsequent improvements
involve the introduction of new options to the Swift driver and
Swift frontend:
  1. `-windows-sdk-root`
  2. `-windows-sdk-version`
  3. `-visualc-tools-root`
  4. `-visualc-tools-version`
The introduction of these options will then feed into the path selection
here enabling granular control over the VCRuntime and Windows SDK by the
user.

Thanks to @artemcm for the very helpful discussion and help on
identifying a good set of options for the driver.  Thanks to @stevapple
for the inspiration for this patch.
2023-03-02 15:56:14 -08:00
Erik Eckstein
ab1b343dad use new llvm::Optional API
`getValue` -> `value`
`getValueOr` -> `value_or`
`hasValue` -> `has_value`
`map` -> `transform`

The old API will be deprecated in the rebranch.
To avoid merge conflicts, use the new API already in the main branch.

rdar://102362022
2022-11-21 19:44:24 +01:00
Butta
f82a4e7899 [ClangImporter] Add the sysroot directly to the clang Driver used to find the libc header path
`getToolChain()` and `AddClangSystemIncludeArgs()` don't parse the arguments to set the
sysroot, so set it directly instead. Also, remove a redundant check for a valid directory.

Fixes #60224
2022-08-27 01:24:33 +05:30
3405691582
6a55161187 Correct VFS libc modulemap injection condition.
We should only be skipping VFS libc modulemap injection on Darwin and
Windows. Unfortunately, we cannot just use the isOSGlibc Triple method
because LLVM's sense of Glibc (does the platform _actually use_ glibc)
differs from Swift's sense of Glibc (does the platform use libc).

There may be other non-libc platforms that we should skip VFS injection
on but let's correct the conditional for now and other prs should add
those platforms as necessary.
2022-08-17 16:25:00 -04:00
Egor Zhdan
59cc7c49e3 [cxx-interop] NFC: fix bad merge
`getModuleMapFilePath` and related logic was moved to `ClangIncludePaths.cpp` recently, but got resurrected in `ClangImporter.cpp` by accident.
2022-07-08 12:41:46 +01:00
Egor Zhdan
cf3354222d [Glibc] Use VFS to inject modulemap into Glibc include path
This will fix modularization issues caused by the presence of Glibc and libstdc++ in a single context.

Some Glibc headers were getting hijacked by the libstdc++ module, and the decls in them were incorrectly determined to be a part of libstdc++. This caused compiler errors when trying to use those decls.

After this change, we will be able to reference Glibc headers directly from the module map, without using an additional header (`SwiftGlibc.h`).
2022-07-01 23:49:12 +01:00
Egor Zhdan
a2fb2d0b78 [ClangImporter] NFC: extract Clang include path mapping logic into a separate file
This logic is going to be extended to inject the modulemap and the header of Glibc in addition to libstdc++. It doesn't depend on the rest of ClangImporter, so let's extract it to a separate file to make incremental builds and IDE features faster.
2022-06-30 15:50:33 +01:00