aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/link-rule.cxx
AgeCommit message (Collapse)AuthorFilesLines
2024-09-30Add ability to specify custom MSVC /MACHINE valueBoris Kolpackov1-10/+24
This, for example, can be used to link for ARM64EC instead of the default ARM64: "config.cxx=cl.exe /arm64EC" config.cc.loptions=/MACHINE:ARM64EC
2024-09-05Fix bug in whole archive prerequisite change trackingBoris Kolpackov1-3/+3
2024-09-05Don't suppress duplicate libraries if linking whole archive (GH issue #411)Boris Kolpackov1-3/+10
2024-08-06Add support for specifying compile options on exe/lib{} targetsBoris Kolpackov1-34/+350
It is now possible to specify compile option (*.poptions and *.coptions) on the exe/lib{} targets (we call them "binary-specific compile options"). Such options are propagated to obj/bmi{} targets that are synthesized for source prerequisites of the binary. Note that this propagation does not apply to obj/bmi{} prerequisites. For example: exe{foo}: cxx{foo} obj{common} { cxx.poptions += -DFOO } exe{bar}: cxx{bar} obj{common} { cxx.poptions += -DBAR } obj{common}: cxx{common} { cxx.poptions += -DCOMMON } In this example, cxx{foo} will be compiled with -DFOO, cxx{bar} -- with -DBAR, and cxx{common} -- with -DCOMMON. Note that if a source prerequisite is shared between several binaries, then the values of the propagated compile options (or their absence) must match. For instance, the following variant of the above example would result in an error since cxx{common} would have contradictory cxx.poptions values: exe{foo}: cxx{foo common} { cxx.poptions += -DFOO } exe{bar}: cxx{bar common} { cxx.poptions += -DBAR } As another example, here is how we can rewrite a typical library buildfile (which requires different macros to distinguish between shared/static builds) using this mechanism, in this case, to build two libraries in the same scope: ./: lib{foo}: {hxx cxx}{*-foo} ./: lib{bar}: {hxx cxx}{*-bar} cxx.poptions =+ "-I$out_root" "-I$src_root" lib{foo}: { cxx.poptions += -DFOO cxx.export.poptions = "-I$out_root" "-I$src_root" } liba{foo}: { cxx.poptions += -DLIBFOO_STATIC_BUILD cxx.export.poptions += -DLIBFOO_STATIC } libs{foo}: { cxx.poptions += -DLIBFOO_SHARED_BUILD cxx.export.poptions += -DLIBFOO_SHARED } lib{bar}: { cxx.poptions += -DBAR cxx.export.poptions = "-I$out_root" "-I$src_root" } liba{bar}: { cxx.poptions += -DLIBBAR_STATIC_BUILD cxx.export.poptions += -DLIBBAR_STATIC } libs{bar}: { cxx.poptions += -DLIBBAR_SHARED_BUILD cxx.export.poptions += -DLIBBAR_SHARED } The exact semantics of this mechanism is as-if the binary-specific compile options were set on the synthesized obj/bmi{} targets at the end of the buildfile. One nuance to keep in mind is that target type/pattern-specific assign/append/prepend specified for obj/bmi{} will not be in effect for options specified on lib/exe{}. For example: cxx.poptions += -DSCOPE obj{*}: cxx.poptions += -DTARGET exe{foo}: cxx.poptions += -DFOO Here the effective cxx.poptions for exe{foo} prerequisites will be -DSCOPE -DFOO since exe{foo} does not match the obj{*} pattern. As result, if using this mechanism, remember to include the binary target types in obj{} patterns. For example: {obj exe}{*}: cxx.poptions += -DTARGET
2024-07-31Add lookup limit to {scope,target}::lookup_original()Boris Kolpackov1-5/+5
2024-06-07Use combined -L option form for extra system search pathsBoris Kolpackov1-4/+10
The split one was just too much of an eye-sore in the logs.
2024-06-07Add comment on not adding rpath for /usr/local/libBoris Kolpackov1-0/+18
2024-06-05Improve -rpath duplicate suppression logic even moreBoris Kolpackov1-2/+11
2024-06-05Improve -rpath duplicate suppression logic some moreBoris Kolpackov1-3/+15
2024-06-05Include top-level libraries in -rpath duplicate suppression logicBoris Kolpackov1-0/+7
2024-02-26Add ability to serialize compilation/linking in cc rulesBoris Kolpackov1-8/+25
Specifically, both the C/C++ compiler and link rules now recognize the cc.serialize boolean variable which instructs them to compiler/link serially with regards to any other recipe. This is primarily useful when compiling large translation units or linking large binaries that require so much memory that doing that in parallel with other compilation/linking jobs is likely to summon the OOM killer. For example: obj{memory-hog}: cc.serialize = true
2024-02-22Detect non-cc::link_rule libraries not marked with cc.type=ccBoris Kolpackov1-4/+11
Fixes GH issue #368.
2024-02-15Add fsdir{} duplicate suppression in more placesBoris Kolpackov1-1/+7
2024-01-11Properly split injected ad hoc group member name in regex pattern ruleBoris Kolpackov1-1/+2
2024-01-10Fix bunch of typosBoris Kolpackov1-2/+2
2023-12-12Work around unexecuted member for installed libraries issueBoris Kolpackov1-3/+26
See comment for the long-term plan.
2023-12-03Reimplement search_existing() functions via target_type::searchBoris Kolpackov1-1/+1
This allows us to automatically get the target type-specific behavior with regards to the out_only semantics (added in the previous commit) instead of passing it explicitly from each call site.
2023-11-22Fix cc::link_rule and cc::install_rule to recognize S{} even in C++Boris Kolpackov1-10/+6
Failed that, a C++ link rule cannot match a dependency with S{} prerequisites.
2023-11-09Minor fix to diagnosticsBoris Kolpackov1-1/+1
2023-08-22Consider *_inc{} target types as headers for rule match purposesBoris Kolpackov1-2/+5
2023-06-28Minor tweaks and cleanupsBoris Kolpackov1-0/+3
2023-04-18Add support for Assembler with C Preprocessor (.S) compilationBoris Kolpackov1-6/+12
Specifically, the c module now provides the c.as-cpp submodules which can be loaded in order to register the S{} target type and enable Assembler with C Preprocessor compilation in the c compile rule. For details, refer to "Assembler with C Preprocessor Compilation" in the manual.
2023-04-10Fix inconsistent /usr/local/{include,lib} searchBoris Kolpackov1-10/+9
In particular, we were adding -L/usr/local/lib which means it is considered before built-in directories (/usr/lib, etc) but in our own library search code we were considering it after (because we were storing it at the end of sys_lib_dirs). Now in both sys_{hdr,lib}_dirs we store /usr/local/{include,lib} after mode and before built-in directories. Note that as part of this fix we now pass -isystem /usr/local/include instead of -idirafter (which is consistent with the -L behavior and also the customarily expected semantics).
2023-04-05Allow creating context with bare minimum of initializationsBoris Kolpackov1-2/+2
This is used by bpkg to detect forwarded configurations without incurring the full context creation overhead.
2023-03-22Initial work on relocatable install: config.install.relocatable and rpathBoris Kolpackov1-2/+66
2022-12-09Enable diagnostics color in GCC and ClangBoris Kolpackov1-0/+2
2022-11-30Diagnose absence of import library after link.exe invocation (GH issue #231)Boris Kolpackov1-7/+22
If a library does not export any symbols then link.exe skips creating the import library.
2022-11-29Fix backlink logic for target groupsBoris Kolpackov1-5/+24
We used to backlink ad hoc group members both via the group and as individual members. And for explicit groups it was done only via individual members, which means it only works correctly if every member is individually updated. Now both types of groups are backlinked from the group target.
2022-11-23Rework diag_buffer interface to facilitate correct destruction orderBoris Kolpackov1-11/+13
2022-11-22Add support for Objective-C/C++ compilation in cc moduleBoris Kolpackov1-33/+46
2022-11-16Initial low verbosity diagnostics reworkBoris Kolpackov1-1/+1
2022-11-08Make process exit diagnostics consistentBoris Kolpackov1-3/+6
In particular, we now always print error message on non-0 exit except in cases where such exit is ignored.
2022-11-08Tighten args const-ness in the run*() function familyBoris Kolpackov1-4/+0
2022-11-08More work on child process diagnostics bufferingBoris Kolpackov1-16/+3
2022-10-27Initial work on child process diagnostics bufferingBoris Kolpackov1-38/+68
Currently this is implemented for C/C++ compile and link rules.
2022-10-21Add clarifying commentBoris Kolpackov1-0/+4
2022-10-10Preparatory work for public/private variable distinctionBoris Kolpackov1-1/+7
We still always use the public var_pool from context but where required, all access now goes through scope::var_pool().
2022-09-28Omit -l for binless libraries, metadata from common .pc fileBoris Kolpackov1-1/+0
Having -l options for binless (header-only) libraries makes it unusable from other build systems. But omitting them could make the metadata incomplete (for example, importable headers), so we omit that as well.
2022-08-16Improve MSVC /DEBUG option handlingBoris Kolpackov1-19/+26
Specifically, handle the /DEBUG:<value> form in addition to /DEBUG and recognize /DEBUG:NONE.
2022-07-26Disable risky sanity checkBoris Kolpackov1-1/+3
2022-07-21Fix bug in common .pc file generation logic (GitHub issue #198)Boris Kolpackov1-1/+1
2022-06-29Work around MSVC 14.3 issuesBoris Kolpackov1-2/+2
2022-06-29Make sure we generate common pkg-config file for only liba{}/libs{}Boris Kolpackov1-2/+19
2022-06-28Complete support for saving/loading library metadata to/from pkg-config filesBoris Kolpackov1-5/+21
2022-06-24Allow ad hoc rules not to list targets that are updated during matchBoris Kolpackov1-7/+11
For example, this allows a Qt moc rule not to list generated headers from libQtCore since they are pre-generated by the library.
2022-06-24Add ability to get common interface options via $x.lib_poptions()Boris Kolpackov1-3/+12
Specifically, the output target type may now be omitted for utility libraries (libul{} and libu[eas]{}). In this case, only "common interface" options will be returned for lib{} dependencies. This is primarily useful for obtaining poptions to be passed to tools other than C/C++ compilers (for example, Qt moc).
2022-06-24Match libraries before update for install prerequisites in cc::link_ruleBoris Kolpackov1-4/+11
2022-05-23Detect cross-linking and pass -rpath-link in addition to -rpathBoris Kolpackov1-7/+69
According to the GNU ld documentation (and painful practical experience), -rpath does not always imply -rpath-link for cross-linkers.
2022-05-05Recognize -pthread as king of -l in *.libsBoris Kolpackov1-2/+12
2022-05-05Allow linking libraries without any sources/headers with hintBoris Kolpackov1-3/+8
This can be useful for creating "metadata libraries".