File: Package.swift

package info (click to toggle)
swiftlang 6.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,856,264 kB
  • sloc: cpp: 9,995,718; ansic: 2,234,019; asm: 1,092,167; python: 313,940; objc: 82,726; f90: 80,126; lisp: 38,373; pascal: 25,580; sh: 20,378; ml: 5,058; perl: 4,751; makefile: 4,725; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (51 lines) | stat: -rw-r--r-- 2,420 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// swift-tools-version: 5.8

import PackageDescription

let package = Package(
    name: "FuzzTesting",
    products: [
        // Discussion: Why we build libraries instead of executables linking libFuzzer?
        //
        // First, libclang_rt.fuzzer.a defines the main function for the fuzzing process
        // and object files given by the user are expected not to have a "main" function
        // to avoid conflicts.
        // Fortunately, SwiftPM asks the compiler frontend to define the main entrypoint as
        // `<module_name>_main` for testing executable targets (`-entry-point-function-name`)
        // so object files of `executableTarget` targets are capable of being linked with
        // libclang_rt.fuzzer.a.
        // However, at link-time, SwiftPM asks the linker to rename the `<module_name>_main`
        // symbol back to `main` for the final executable (`--defsym main=<module_name>_main`)
        // and gold linker respects the renamed "main" symbol rather than the one defined in
        // libclang_rt.fuzzer.a, so the final executable does not start the fuzzing process.
        //
        // Instead of relying on the SwiftPM's linking process, we build libraries defining
        // fuzzing target functions and manually link them with fuzzing runtime libraries.
        .library(name: "FuzzTranslator", type: .static, targets: ["FuzzTranslator"]),
        .library(name: "FuzzExecute", type: .static, targets: ["FuzzExecute"]),
        // FuzzDifferential is not a libFuzzer-based target, so we build it as an executable.
        .executable(name: "FuzzDifferential", targets: ["FuzzDifferential"]),
    ],
    dependencies: [
        .package(path: "../"),
    ],
    targets: [
        .target(name: "FuzzTranslator", dependencies: [
            "WasmKitFuzzing",
            .product(name: "WasmKit", package: "WasmKit")
        ]),
        .target(name: "FuzzExecute", dependencies: [
            "WasmKitFuzzing",
            .product(name: "WasmKit", package: "WasmKit"),
        ]),
        .executableTarget(name: "FuzzDifferential", dependencies: [
            .product(name: "WasmKit", package: "WasmKit"),
            .product(name: "WAT", package: "WasmKit"),
            "WasmCAPI",
        ]),
        .target(name: "WasmCAPI"),
        .target(name: "WasmKitFuzzing", dependencies: [
            .product(name: "WasmKit", package: "WasmKit"),
        ])
    ]
)