Skip to content

Commit e68172f

Browse files
committed
Swift: fetch prebuilt swift and link against it
This is known to break linux integration in sembuild.
1 parent 058ac5b commit e68172f

File tree

4 files changed

+47
-1
lines changed

4 files changed

+47
-1
lines changed

misc/bazel/workspace.bzl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
33

44
def codeql_workspace():
5+
for arch, repo_arch, sha256 in (
6+
("linux", "linux", "48e39228e49aa560f0c1e504c4f9d488e28278b31fedc8271ce4cf807d9f7791"),
7+
("darwin_x86_64", "macos-x86_64", "8f1e8e9cfb4391b3fbc0b90da548a7e660f302b1a8551e6640e8a944eb377028"),
8+
):
9+
http_archive(
10+
name = "swift_prebuilt_%s" % arch,
11+
url = "https://github.com/dsp-testing/codeql-swift-artifacts/releases/download/swift-5.6-RELEASE.42271.49/swift-prebuilt-%s.zip" % repo_arch,
12+
build_file = "@ql//swift/extractor:BUILD.swift-prebuilt.bazel",
13+
sha256 = sha256,
14+
)
15+
516
maybe(
617
repo_rule = http_archive,
718
name = "rules_pkg",

swift/extractor/BUILD.bazel

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
alias(
2+
name = "swift-llvm-support",
3+
actual = select({
4+
"@bazel_tools//src/conditions:%s" % arch: "@swift_prebuilt_%s//:swift-llvm-support" % arch
5+
for arch in ("linux", "darwin_x86_64", "darwin_arm64")
6+
}),
7+
)
8+
19
cc_binary(
210
name = "extractor",
311
srcs = ["main.cpp"],
@@ -7,4 +15,5 @@ cc_binary(
715
"//conditions:default": ["@platforms//:incompatible"],
816
}),
917
visibility = ["//swift:__pkg__"],
18+
deps = [":swift-llvm-support"],
1019
)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
cc_library(
2+
name = "swift-llvm-support",
3+
srcs = glob([
4+
"libswiftAndLlvmSupportReal.a",
5+
"libswiftAndLlvmSupportReal.so",
6+
]),
7+
hdrs = glob(["include/**/*"]),
8+
linkopts = [
9+
"-lm",
10+
"-lz",
11+
] + select({
12+
"@platforms//os:macos": ["-lcurses"],
13+
"@platforms//os:linux": [
14+
"-luuid",
15+
"-lrt",
16+
"-lpthread",
17+
"-ltinfo",
18+
"-ldl",
19+
],
20+
}),
21+
strip_include_prefix = "include",
22+
visibility = ["//visibility:public"],
23+
)

swift/extractor/main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#include <iomanip>
33
#include <stdlib.h>
44

5-
int main() {
5+
#include <swift/Basic/LLVMInitialize.h>
6+
7+
int main(int argc, char** argv) {
8+
PROGRAM_START(argc, argv);
69
if (auto trapDir = getenv("CODEQL_EXTRACTOR_SWIFT_TRAP_DIR")) {
710
std::string file = trapDir;
811
file += "/my_first.trap";

0 commit comments

Comments
 (0)