Commit Graph

560 Commits

Author SHA1 Message Date
Paolo Tranquilli
874fe2b8f9 Swift: introduce an in-memory file hash cache
File hashing is now done internally in `SwiftFileInterception` (and
exported as a `getHashOfRealFile` function for future use in linkage
awareness), and using a per-process in-memory cache. The persistent
caching of paths is removed, so the solution is now robust against input
file changes during the build.

For the same reason, the hash to artifact mapping have the symlinks
reversed now. The artifacts themselves are stored using the hash as
filenames, and the original paths of the artifacts are reacreated in the
scratch dir with symlinks mostly for debugging purposes (to understand
what artifact each hash corresponds to, and to follow what was built by
the extractor).
2023-01-16 12:05:36 +01:00
Paolo Tranquilli
4f5f0aad45 Merge branch 'main' into redsun82/swift-open-redirection 2023-01-12 10:54:04 +01:00
Paolo Tranquilli
2fb5621527 Swift: replace $(CC) with clang
On macOS `$(CC)` points to a wrapper that requires `DEVELOPER_DIR` to be
set in the environment. Using `clang` is slightly less generic, but
that's our default any way. Even if we do set a different clang version
somewhere, the selected version of GCC would not change, and the test
is targeting that.
2023-01-10 14:58:21 +01:00
Paolo Tranquilli
943763a026 Swift: add -Wno-pragma-once-outside-header to check 2023-01-10 14:30:35 +01:00
Paolo Tranquilli
28d79eeb77 Swift: make compilation with different STL versions possible
Previous to this patch the code contained a workaround for the standard
defect

https://cplusplus.github.io/LWG/issue3657

where `std::filesystem::path` did not have a `std::hash` implementation.

This patch allows compiling against versions of the STL that contain the
fix to the above issue. This is done by running the compiler against
code defining `std::hash<std::filesystem::path>`: if compilation
succeeds, it means the fix is not there and we need to use the
workaround, contained in `PathHash.h.workaround`. Otherwise, the fix is
there and we use `PathHash.h.fixed` instead, which only includes the
standard headers included by `PathHash.h.workaround`, so that one is a
drop-in replacement of the other.
2023-01-10 14:14:33 +01:00
Paolo Tranquilli
82d9edfabf Merge branch 'main' into redsun82/swift-open-redirection 2023-01-09 08:44:02 +01:00
Paolo Tranquilli
454af0d721 Swift: fix locking of output swiftmodule trap 2022-12-20 15:34:18 +01:00
Nora Dimitrijević
1c64bf4bbc Swift: remove superfluous newline 2022-12-19 18:00:20 -05:00
Nora Dimitrijević
60727b1e5e Swift: Fix Builtin(Types) test extraction failure 2022-12-15 10:47:10 -05:00
Paolo Tranquilli
7f505d8715 Swift: do not filter frontend actions 2022-12-15 14:39:43 +01:00
Paolo Tranquilli
208388e04d Swift: hard code libc.dylib path on macOS
Also, handle the corner case where loading libc fails.
2022-12-15 13:30:23 +01:00
Paolo Tranquilli
e42ae09e1c Swift: fix interaction between bash wrapper and open redirection on macOS 2022-12-15 09:50:31 +01:00
Nora Dimitrijević
7ea0eada11 Swift: add missing Builtin symbols 2022-12-14 20:03:41 -05:00
Paolo Tranquilli
14fd89d482 Swift: generalize output redirection code 2022-12-14 18:26:48 +01:00
Paolo Tranquilli
45c0c7fe6c Merge branch 'main' into redsun82/swift-open-redirection 2022-12-14 18:26:16 +01:00
Paolo Tranquilli
de2e92d5e1 Swift: remove / delimiters from regex extracted patterns 2022-12-14 09:18:36 +01:00
Paolo Tranquilli
fb5b6eab19 Swift: extract RegexLiteralExpr 2022-12-14 09:12:07 +01:00
Alex Denisov
ee94849528 Swift: switch to bootstrapped Swift compiler 2022-12-13 13:59:13 +01:00
Paolo Tranquilli
03d7adb303 Swift: wrap extractor with shell script
This is in preparation for the extractor to use shared libraries
packaged alongside it.

We could probably also move the `CODEQL_EXTRACTOR_SWIFT_RUN_UNDER` logic
in it, where it would be simpler and more robust.
2022-12-13 09:07:37 +01:00
Paolo Tranquilli
7162692656 Swift: exit directly on actions not requiring extraction 2022-12-09 10:00:01 +01:00
Paolo Tranquilli
4a41bb4061 Merge branch 'main' into redsun82/swift-open-redirection 2022-12-09 09:59:21 +01:00
Paolo Tranquilli
bf1b32f210 Swift: rework file redirection
The hash map mechanism that was already in use for reading swiftmodule
files on macOS is now in use also on Linux. The output replacing
mechanism has been also reworked so that:
* frontend module emission modes have the remapping done directly in
  the internal frontend options instead of painstakingly modifying input
  flags (this requires a patch on the swift headers though)
* object emission mode is silenced to be just a type checking pass,
  thus producing no output files
* all other passes but some debugging and version related ones become
  noops

The open file read redirection uses a global weak pointer instance to
maximize robustness in the face of possibly multi-threaded calls to open
happening while `main` is exiting. Possibly overkill, but better safe
than sorry.
2022-12-08 16:10:44 +01:00
Paolo Tranquilli
1ba8b6d35a Swift: fix extraction of sources from .. 2022-12-08 15:57:57 +01:00
Alex Denisov
f5ddbd6abb Swift: add a test case showing case canonicalization 2022-12-02 14:06:21 +01:00
AlexDenisov
691188bc48 Merge pull request #11523 from github/alexdenisov/preserve-symlinks
Swift: resolve symlinks conditionally
2022-12-02 14:05:13 +01:00
Alex Denisov
7a3beac494 Swift: resolve symlinks conditionally 2022-12-02 10:07:10 +01:00
Paolo Tranquilli
1b6a50147a Merge branch 'main' into redsun82/swift-type-mapping
Conflict resolved on addition of `AbiSafeConversionExpr`
2022-12-02 09:02:47 +01:00
Alex Denisov
0bfe502bb0 Swift: remove patches from the extractor
Moved elsewhere https://github.com/dsp-testing/codeql-swift-artifacts/pull/3
2022-11-30 15:36:09 +01:00
Alex Denisov
67fb56deb8 Swift: workaround an internal crash coming from Swift 5.7.1 2022-11-30 12:40:42 +01:00
Alex Denisov
f618d53302 Swift: add new implicit conversion 2022-11-30 12:40:34 +01:00
Nora Dimitrijević
931173350f Swift: extract missing cases of AccessorKind and AccessSemantics
This resolves the warnings that were showing up during extractor-pack
compilation.
2022-11-29 11:31:07 +01:00
Nora Dimitrijević
36e7235493 Swift: fix -Wmissing-braces warning in extractor
By initializing va_list the standard way,
i.e. leaving it uninitialized until va_start().
2022-11-29 11:31:07 +01:00
Nora Dimitrijević
c89c449a2c Swift: silence cmake/vscode intellisense Problem
i.e. "TrapLabel not found"
2022-11-29 11:27:33 +01:00
Paolo Tranquilli
edddaaa838 Swift: make mapping from swift types to tags explicit
This should decouple schema names from swift names, allowing to
rename schema names regardless of internal swift compiler names.
2022-11-25 13:10:33 +01:00
Paolo Tranquilli
545c2f67e9 Merge pull request #11382 from github/alexdenisov/swift-relax-file-archiving
Swift: do not abort if cannot archive a source file
2022-11-23 06:56:26 +01:00
Alex Denisov
8f02463411 Swift: fix remapping bug
This issue has slipped during a recent refactoring:
https://github.com/github/codeql/pull/10987/files#diff-c5ab26a06a93c4507a834859a6a56878d5bfe16c4d7cbac4afc4f081d46f461aL63-R64
2022-11-22 17:25:07 +01:00
Alex Denisov
a2ac1384cb Swift: do not abort if cannot archive a source file 2022-11-22 17:18:40 +01:00
Paolo Tranquilli
3816361c15 Merge branch 'main' into redsun82/swift-types 2022-11-11 13:54:12 +01:00
Paolo Tranquilli
41977d1dbb Swift: implement extraction of new properties 2022-11-11 12:49:48 +01:00
Paolo Tranquilli
88dc65cb3c Swift: extract or ignore last remaining types 2022-11-10 17:38:32 +01:00
Paolo Tranquilli
458fb3a4a2 Swift: fix printing of unextracted entities
This was still printing explicitly ignored classes.
2022-11-10 16:49:32 +01:00
Paolo Tranquilli
5b9e89acd3 Swift: implement ignoring of removed classes 2022-11-10 15:26:55 +01:00
Paolo Tranquilli
edfecddca1 Swift: extract AppliedPropertyWrapperExpr 2022-11-10 12:55:28 +01:00
Paolo Tranquilli
28c9d6b6b5 Swift: extract PropertyWrapperValuePlaceholderExpr 2022-11-10 11:28:05 +01:00
Paolo Tranquilli
0ccf81e67c Swift: extract UnresolvedSpecializeExpr 2022-11-09 16:42:22 +01:00
Paolo Tranquilli
1a062823ee Swift: extract DynamicLookupExpr 2022-11-09 16:31:59 +01:00
Paolo Tranquilli
e2bdef2fba Swift: extract DynamicMemberRefExpr 2022-11-09 16:22:22 +01:00
Paolo Tranquilli
4770ad3177 Swift: extract OverloadedDeclRefExpr 2022-11-09 16:06:23 +01:00
Paolo Tranquilli
5f8e7e67b4 Swift: extract ObjectLiteralExpr 2022-11-09 15:51:08 +01:00
Paolo Tranquilli
9d4a208c0d Swift: extract MissingMemberDecl 2022-11-09 12:04:42 +01:00