GCC Code Coverage Report


Directory: ../
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 1
Functions: 0.0% 0 / 0 / 1
Branches: -% 0 / 0 / 0

src/linker/ExternalLinkerInterface.h
Line Branch Exec Source
1 // Copyright (c) 2021-2026 ChilliBits. All rights reserved.
2
3 #pragma once
4
5 #include <atomic>
6 #include <filesystem>
7 #include <string>
8 #include <vector>
9
10 namespace spice::compiler {
11
12 // Forward declarations
13 struct CliOptions;
14
15 class ExternalLinkerInterface {
16 public:
17 // Constructors
18 explicit ExternalLinkerInterface(const CliOptions &cliOptions);
19
20 // Avoid copies
21 ExternalLinkerInterface(const ExternalLinkerInterface &) = delete;
22 ExternalLinkerInterface &operator=(const ExternalLinkerInterface &) = delete;
23
24 // Public methods
25 void prepare();
26 void run() const;
27 void cleanup() const;
28 void addFileToLinkage(const std::filesystem::path &path);
29 void addLinkerFlag(const std::string &flag);
30 void addAdditionalSourcePath(std::filesystem::path additionalSource);
31 void requestLibMathLinkage();
32 [[nodiscard]] const std::vector<std::string> &getLinkerFlags() const { return linkerFlags; }
33 [[nodiscard]] const std::vector<std::filesystem::path> &getLinkedFiles() const { return linkedFiles; }
34
35 // Public members
36 std::filesystem::path outputPath;
37
38 private:
39 // Private methods
40 void link() const;
41 void archive() const;
42
43 // Members
44 const CliOptions &cliOptions;
45 std::vector<std::filesystem::path> linkedFiles;
46 std::vector<std::string> linkerFlags;
47 // The IR generator requests libm linkage while emitting certain operators, so this flag is written from the back-end
48 // worker threads. Everything else on this class is only touched from the single-threaded phases of the pipeline.
49 std::atomic<bool> linkLibMath = false;
50 };
51
52 } // namespace spice::compiler
53