645 commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
dc8e9e6f9e |
feat(test): give a test that sets Test::wayland a compositor of its own
A test that opens a window opened it on the display of whoever ran the suite: every `crafter-build test` of Crafter.Graphics put the windows of its window tests on the desktop, and its other GPU tests connect to the session's compositor too, since Device::Initialize calls wl_display_connect whether a window follows or not. A test that sets the new Test::wayland (TestBuilder::Wayland) now runs with a headless compositor started for it alone. RunSingleTest starts the compositor through sh, with XDG_RUNTIME_DIR naming a directory made for it and without WAYLAND_DISPLAY, WAYLAND_SOCKET or DISPLAY, waits up to 30 s for a wayland-<n> socket in that directory, runs the test with WAYLAND_DISPLAY set to the socket's path and with DISPLAY and WAYLAND_SOCKET unset, then stops the compositor's process group and removes the directory. The test's command is env with those changes, and env's command is sh, which execs the test's words: env takes every word with an '=' in it ahead of its command for an assignment, a binary's path among them. The compositor runs under timeout(1) as long as the test may, the wait and 30 s more, and with no limit for a test that has none, a timeout of 0. It is weston on its headless backend with its GL renderer, unless CRAFTER_BUILD_COMPOSITOR or the new --compositor= names another command; `host` gives the tests the session's own display instead, to watch them. A compositor that ends before it listens, sh not finding it included, or does not listen in time fails the test with what it printed. A test that may run where its compositor is missing declares it in requires_ (tool:weston for the default), the check RunTests makes before the build, so no skip of its own is added, and no probe of the command: the command is any sh command, whose first word need not be the compositor. A test that fails, crashes or times out keeps what its compositor printed (TestResult::compositorLog), which RunTests writes to build/test-logs/<name>.compositor.log, and says when the compositor ended while it ran. One compositor per test rather than one per run: no two tests share one, so tests that run at once cannot cover each other's windows or take each other's focus, for weston's start-up on every test. weston's GL renderer, because it imports the dmabufs that a GPU's Vulkan driver presents, as Mesa's and NVIDIA's do, and the headless backend's default renderer and pixman import none: against pixman, the NVIDIA driver reports no format for a window's surface, and Crafter.Graphics's FrameLoopSync stops at its formatCount > 0 assertion. weston cannot run the test itself, as `weston -- <test>` exits 0 whatever the test returned, so crafter-build runs the compositor beside it. :Platform gains BackgroundCommand, the compositor's process, and PrivateDirectory, its directory. The process is forked with PR_SET_PDEATHSIG and runs under `timeout`, which passes the SIGTERM it gets when crafter-build dies on to the compositor's group, so a crafter-build killed by Ctrl-C leaves no compositor running. The directory is made in $XDG_RUNTIME_DIR, or in /tmp where that is not a directory, rather than in the temp directory, since a socket's path holds 107 bytes, and is flocked while in use; one that a killed crafter-build left is removed when the next is made beside it, once it has not changed for a minute. New members and a parameter with a default, nothing removed: a minor release. |
|||
|
cb8914d387 |
docs(packaging): add the 6.4.3 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 13m58s
6.4.3 has lint parse a file for the rules that read its AST with the libc++ of the compiler that builds it, so that in the Flatpak those rules run on a file that includes a header of the C++ standard library (#46), and gives the scan of a build's sources the compiler where it is installed, so that a build whose compiler is reached through a link from another directory scans them. A patch, by the version rule: the notes have Fixes and nothing New or Breaking. The range adds Toolchain::installedDir, Toolchain::installedDirAsWritten and Toolchain::InstalledClangxx(command), which interfaces/ exports, for the linter and the scan to read. They are not under New, as ObjectPath, which 6.4.1 exported for the tests, was not. |
|||
|
fe25d7aeff |
test(lint): the ast and ast-module cases pass only when their rule ran
RunLint calls a rule that reads the AST only on a file it could parse, so when the parse failed, the checks inside the "ast" and "ast-module" rules went untried, and the test, which read nothing of the run but those checks, passed. That is how the "ast" case, whose file includes <string>, passed in crafter-build's Flatpak with #46 open: lint printed "'string' file not found" for that file, and the test exited 0. Both cases now also check that their rule ran and that the run had no error. |
|||
|
043b1a3015 |
test(lint): a compiler installed in a directory of its own
LintCompilerHeaders stages an installation of its own: the toolchain's compiler copied into install/bin, beside links to the rest of the real installation, and one header more in its c++/v1, crafter_issue46.h. The toolchain it points the build at with CRAFTER_BUILD_LLVM_DIR has a bin/clang++ that links to that copy, and no include directory. The compiler runs from install/bin, so the compile of a file that includes <algorithm> and crafter_issue46.h finds both, and the build's scan of the file and lint's parse of it have to as well. Without the lint fix the parse fails on crafter_issue46.h on a host whose /usr has a libc++, and on <algorithm> in crafter-build's Flatpak, whose /usr has none. It fails in the same two ways with argv[0] taken from the compile command, llvm/bin/clang++. Without the scan fix the scan, given llvm/bin/clang++ as well, fails the same two ways, and the build with it, which the test's first check reports. The compiler is copied because a link would lead clang back to the real installation, and the copy is of the clang++ in the directory `clang++ --version` names, so that a wrapper on PATH that runs the compiler is not copied in its place. The test takes CRAFTER_BUILD_LIBCXX_DIR out of its environment, which would have every compile take that libc++ in place of the staged one, and the std module the staged toolchain builds goes to a cache of its own. It skips where it cannot stage the compiler: where no clang++ is found, the compiler's installation has no libc++ headers of its own, no llvm-ar or clang-scan-deps is beside the compiler, or the copy names no resource directory it has. A second configuration on the same toolchain passes -no-canonical-prefixes, with which the compiler takes itself to be in llvm/bin, as written, and reads the clang++.cfg the test writes there, which adds a directory only it names; its file includes the one header that directory holds, and none of the C++ standard library, which llvm/ has no include directory for. Given install/bin/clang++ whatever the command's prefix flags, the scan fails on that header, and the build with it, and so does the parse. The test takes CLANG_NO_DEFAULT_CONFIG out of its environment as well, which would have clang read no configuration file, and where the compile with the flag still does not read the file beside the link, as where a user or system configuration directory holds a clang++.cfg, or a <triple>-clang++.cfg, that clang finds first, it leaves the second configuration out and skips, unless the first configuration failed. |
|||
|
090d8f6363 |
fix(build): scan sources with the compiler where it is installed
clang-scan-deps, which reads what a .cppm or .cpp declares and imports since 6.4.2, builds a clang driver of its own from the compile command it is given, and that driver looks for clang's own headers, and in a build for the host whose command names no libc++ directory for libc++'s too, from the directory of the command's first word: the toolchain's clangxx, looked up on PATH where it is a bare name, and taken as it stands where it is a link, whatever the command says of canonical prefixes. Where clangxx is a link from another directory, as a CRAFTER_BUILD_LLVM_DIR whose bin/clang++ links into another installation makes it, and the command's last prefix flag is not -no-canonical-prefixes, that directory need not lead to either, and the scan of a source that includes a header of the C++ standard library then failed, and the build with it, on "'stddef.h' file not found" or on the header it included, though the compile, which takes itself to be where the link leads, found them. It is the parse of issue #46 over again, in the scan. The scan is now given the compile command with Toolchain::InstalledClangxx(command) as its first word, the compiler where clang started with that command takes itself to be, as lint's parse is given it: in the directory its --version names, or, for a command whose last prefix flag is -no-canonical-prefixes, in the directory of clangxx as written, from which such a compile looks and from which the scan of it looked before. That directory is also where the driver looks for its default configuration files, clang++.cfg among them, so for any other command the scan now reads the ones beside the compiler, which the compile reads, where it read any beside a link. What is kept of a scan still records the compile command itself, which decides when a source is scanned again: what the source is compiled with has not changed. AGENTS.template.md now says which of the two commands is which. |
|||
|
8019f9d44f |
fix(lint): look for libc++ where the compiler does
In crafter-build's Flatpak, whose compiler keeps libc++ in /app and whose /usr has none, a file that includes a header of the C++ standard library could not be parsed for the lint rules that read its AST in a build like that of #46: the file built, and `crafter-build lint` then ran none of those rules on it, printed "'algorithm' file not found" and exited 1. libclang parses through a clang driver of its own. In a build for the host whose compile command names no libc++ directory, as #46's names none, where a sysroot or CRAFTER_BUILD_LIBCXX_DIR would name one, that driver looks for libc++'s headers under ../include from the directory of its argv[0], then under /usr/local/include and /usr/include. ParseAst gave libclang the compile command without its compiler, and clang_parseTranslationUnit names argv[0] plain "clang", in no directory. So the parse of such a build, natively as in the Flatpak, took the first libc++ it found under ../include from the working directory, /usr/local/include and /usr/include, whichever compiler the build used. The -resource-dir ParseAst passes is for clang's own headers and changes nothing for libc++. The compile command's argv[0] would not do on its own: a clang++ from PATH is the bare name clang++, in no directory either, and a clang++ reached through a link into another directory takes itself to be where the link leads, as clang finds its installation from the file it runs as. The compiler says where that is, on the InstalledDir line of `clang++ --version`, which GetToolchain() already runs for clangVersion. Toolchain::installedDir keeps it, InstalledClangxx(command) names the compiler in it, and ParseAst passes that as argv[0], through clang_parseTranslationUnit2FullArgv, which takes argv[0] from its caller. With argv[0] there, the parse finds libc++ where the compile does, whatever the working directory. A compile command can have the compiler look from elsewhere: with -no-canonical-prefixes, where the last of it and -canonical-prefixes is that one, clang takes itself to be at clangxx as written, or, where no file is there, as is usual for a bare name, at the one PATH gives, a link not followed, and `clang++ -no-canonical-prefixes --version` names that directory. GetToolchain() runs that too, Toolchain::installedDirAsWritten keeps what it names, and InstalledClangxx(command) names the compiler there for a command whose last prefix flag is -no-canonical-prefixes, as clang's own driver reads them. argv[0] also gives libclang's driver its mode, by its file name, and the configuration files it reads by default, from its directory. The parse now runs in the g++ mode the compile runs in, where it ran in clang's gcc mode, and reads the default configuration files beside the compiler that the compile reads, clang++.cfg among them; before, it read none from there, as the driver skips the directory of an argv[0] that has none. -resource-dir stays, for a libclang of another release than the compiler, whose driver would derive the directory from argv[0] for its own release. The comment on it said libclang found clang's own headers relative to its own install path; its driver derived them from argv[0], as it does libc++'s. Fixes #46 |
|||
|
578a1da600 |
docs(packaging): add the 6.4.2 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 14m6s
6.4.2 reads what each .cppm and .cpp declares and imports with
clang-scan-deps, which preprocesses the source with its compile command,
where it searched the source's text with regular expressions (#45), and
so refuses a module built twice for one program, and interface units
that import each other, once the dependencies are built.
A patch, by the version rule: the notes have Fixes and nothing New or
Breaking. The range takes ResolvePendingImports off Configuration, and
the pendingImports members off Module, ModulePartition and
Implementation, all of which interfaces/ exports, and leaves a
configuration's interfaces and implementations empty until a build has
read its sources. All of it is the build's own bookkeeping of a
configuration's units, as Compile() and `compiled` were, which 6.3.0
took off the same unit classes as "internal and not user facing"
(
|
|||
|
efb8fcc8b2 |
docs: what a source imports is read as its compile reads it
The README said that crafter-build reads the imports of a
configuration's sources from their text without compiling them, so that
one in a string literal, in a comment that spans lines or under #if 0
counted, and that a configuration whose interface units import each
other is refused before anything of it is built. It now says that
clang-scan-deps reads what a .cppm or .cpp declares and imports, with
the command the source is compiled with, as the compiler reads it, once
the configuration's dependencies are built; where the build keeps what
it read, as it keeps objects; that such a configuration is refused once
its sources are read, before any of its .cppm and .cpp is compiled; and
that the scans are among the steps a build runs at most as many of at
once as the machine has hardware threads.
The README's sentence on a project that two paths load with different
lists now names the projects the build stops for, those that export
modules, since DuplicateModuleError refuses a module built twice and
nothing else, and says that such a project is built once where both
lists give it one build directory, as two orders of the same flags of
its own can. The README and the contributor guide also stop naming
nlohmann/json among the vendored headers in lib/, which it left in
|
|||
|
15e9831203 |
test(build): one project loaded with its flags in two orders is built once
DuplicateModule builds its project once more with --wide --reorder, with which P gives M the list that A passes on, in the other order. The loader takes the two orders for two lists and makes two configurations of M, which VariantId, taking the project's own flags sorted, builds into one directory, and a pass builds that directory once. The case checks that the two are two configurations with one directory, and then, in two passes, that the graph builds and that P's main.cpp and A's interface have their edges to the module of the configuration of M that the pass built. The first pass builds whichever asks first, and the other has no modules. The second builds the other one first and records it for the directory, as BuildAll records a configuration it builds, before it builds the graph, so that both configurations of M then have modules, the first still those it read in the first pass. On the engine of the range's base the graph is refused as "module M is built twice for P": every configuration had its modules from the listing, and the refusal told the builds apart by their configurations. On an engine that reads a dependency's modules off the configuration it is listed as, the range's fix without BuildResult::built, the first pass builds and A's interface has no edge to M, P's M being the one built and A's having no modules, and the second pass is refused as a graph with two builds of M. |
|||
|
08a506d34b |
test(build): a source's declaration and imports, as its compile reads them
SourceScan builds copies of six fixtures and checks what the build read in their sources, by the modules and units it gives each configuration, and runs the program where what it does depends on that: - text, three of the four inputs of #45: `import Base;` and `import Spaced ;` are imports, and an import in a comment that spans lines or under #if 0 is none. A build with nothing changed then rewrites none of the scans, and one that cannot be read is taken again. - quoted, the fourth: an implementation source whose string literal holds "export module std;" is a unit of no module, and the build succeeds. - partition: a .cppm that declares an implementation partition (`module X:Impl;`) is the partition Impl of X, and the implementation unit that imports it has its edge to it. - define: an #ifdef on a define that the test sets after listing the source decides whether the source imports a module. - switch: an #if on a header of the library the app is built on decides it. The header is edited, and the source is scanned again; then the app is built on another library, whose header of that name says the other thing, so that only the command the scan was taken with has changed. - missing: an #include of a header that is not there fails the build with a message naming the header, and nothing is compiled of the source. On the engine of the range's base, with only this test added, every case but missing fails. Each of the three inputs of the text case is read the old way, and its first build fails outright whenever Spaced.cppm, whose import of Base was missed, is compiled before Base's BMI is there; the string literal makes the listing throw "Module std not found not found", and the implementation partition the listing of the partition case, "No module declaration found"; the import under the #ifdef counts without the define, and the one under the #if after the edit and after the swap; and there is no scan to look at. The missing case passes there too, the compile reporting the header as the scan now does. |
|||
|
3c8f4ddb54 |
fix(build): read what a source declares and imports with clang-scan-deps
GetInterfacesAndImplementations found the module declarations and the imports of a configuration's sources by searching their text with regular expressions, after deleting the comments that fit on one line. The expressions skipped neither string literals nor comments that span lines, knew nothing of the preprocessor, and wanted one space after `import` and none before its semicolon (#45). An implementation source that held "export module std;" in a string literal was taken for a unit of a module std, and listing it threw "Module std not found not found". An import in a comment that spans lines or under #if 0 was followed. `import X;` and `import X ;` were missed, so their unit had no edge to the module it imports and could be compiled before that module's BMI was written. What a .cppm or .cpp declares and imports now comes from clang-scan-deps -format=p1689, which preprocesses the source with the configuration's C++ compile command, the one Build() compiles every unit of it with: strings, comments, spacing, macros and #if come out as they do for the compiler. GetInterfacesAndImplementations only lists the sources, in the new interfaceSources and implementationSources. Build() reads them (ReadSources) once the configuration's dependencies and external dependencies are built: the command takes their include paths, and a source may include headers of an external dependency, which are not there before it is fetched. From what it read, Build() makes the configuration's modules and units, its `interfaces` and `implementations`, and places each import on a module of the configuration or of what it is built on, whose own Build() has read its sources by then. It makes those of its own configuration alone, as the reset of the units' state did before it. A build pass builds a directory once, for whichever configuration of it asks first, and the loader can make two configurations of one directory: one project loaded along two paths with its args in two orders, which it keeps apart and VariantId, sorting the args, does not. Only the one that was built has the modules that build read, so the result of a build now names the configuration it ran on (BuildResult::built), and a dependency's modules are looked up through the pass's record of its directory. 6.4.1 had every configuration's modules from the listing and took such a graph for one with two builds of a module, which it refused; it is now built, once, and the units of both sides have their edges. A scan is kept in the build directory as an object is, in scans/ or, for a source outside cfg.path, in scans-outside/, as JSON of the command it was taken with and of what clang-scan-deps wrote, with the dependency file clang-scan-deps wrote beside it, which lists the source and every file it included. A build scans a source again unless its scan is newer than every file that dependency file lists, was taken with the same command and can be read, so a build with nothing changed runs no clang-scan-deps. Both files are written beside their places and renamed into them, as the archive and the list of objects are, for another crafter-build that may be building the same clone. A configuration's modules are known only once its build has read its sources, so the refusals of a module that two configurations of the graph build (DuplicateModuleError, #41) and of interface units that import each other (ImportCycleError) now come there: once the dependencies are built, before any .cppm or .cpp of the configuration is compiled. They came before the configuration made a directory or built a dependency. The contributor guide names clang-scan-deps among the prerequisites and among what :Toolchain resolves, has a test look at the modules of a configuration only after building it, and has the gotcha for the new order. ResolvePendingImports and the pendingImports of the unit classes go. They placed the imports that a scan at listing time could not, once the dependencies were wired up, and with the imports placed when the dependencies are built there is nothing pending. The tests that looked at a configuration's modules and units before building now look after it (DependencyLink, ModuleInterface, StaticLib, ConcurrentDependencyReset and the disabled TransitiveInterfaceChange), IncrementalInterfaceChange checks the edge that the build of a consumer gives it when its dependency was assigned after its sources were listed, and ImportCycle and DuplicateModule check that the refused configuration compiled nothing of its own. The workarounds for the old scanner are not needed: MingwSysroot writes its stand-in std module as a plain literal again, JobLimit writes the declarations of the sources it generates as plain literals, and Lint's comment on its fixture file no longer gives the scanner as the reason for it. The messages of the regex code stay where they still apply. The one for a source that declares a unit of a module the configuration does not have loses its doubled "not found", and applies to an implementation source that declares one, such as an implementation partition (`module X:P;`). An implementation unit written `module X;` declares no unit for clang-scan-deps but imports X, and an import needs no module of the configuration: the compile reports a module no one builds. A .cppm that declares an implementation partition is built as a partition of its module, where it was refused as declaring no module. The Toolchain gains clangScanDeps, resolved as llvm-ar is: in the bin/ of the LLVM prefix, else by name on PATH. The Flatpak has /app/bin/clang-scan-deps. Fixes #45 |
|||
|
a99647ecff |
docs(packaging): add the 6.4.1 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 17m51s
6.4.1 gives each .cpp, .c and .cu of a configuration an object named
from its path, so that two sources no longer share one for having the
same file name (#50), writes a static library's archive anew, so that
it does not keep the object of a source that left the project, and has
the link and the archive step read their objects from a file, so that
their paths no longer make the command too long to run.
A patch, by the version rule: the notes have Fixes and nothing New or
Breaking. The range changes what Implementation::Check and Schedule
take, which interfaces/ exports, and adds ObjectPath beside
ExpectedOutput, for the tests that look at an object. Check and
Schedule are what Build() itself checks and compiles an implementation
unit with, as Compile() was, which 6.3.0 took off the same class as
"internal and not user facing" (
|
|||
|
9df82bc272 |
docs: where a source's object goes, and what a link reads
The README's "Writing a project.cpp" says that a .cpp, .c or .cu of a configuration is compiled into an object named from its path, under objects/ in the build directory at the source's path from cfg.path, or under objects-outside/ at its whole path for a source outside cfg.path; that two sources may therefore have the same file name in different directories, and a .c lie beside a .cpp or a .cu of its name; that the progress line of such a source's compile names it by that path; and that the link and a static library's archive step read their objects from <outputName>.objects in the build directory. The contributor guide gains two rules beside the one on output paths. ObjectPath() names an object, which is not to be named from its source's file name, and a step that takes every object of a configuration reads them from a response file. And a static library's archive and the list of a step's objects are written under another name beside them and renamed into place, as anything else that a link or archive step of another crafter-build may be reading is to be: two crafter-builds can build a project loaded with GitProject at once, in the clone the cache keeps for its source. |
|||
|
f9bd5333da |
test(build): sources of one file name, and where their objects go
SameNamedSources builds configurations whose sources share file names, on a fresh copy of its fixture outside the checkout, and runs what they link. `names` is an executable of an a/Thing.cpp and a b/Thing.cpp, the C sources a/unit.c and b/unit.c, a b/Thing.c beside the b/Thing.cpp and a Thing.cpp in a directory beside the configuration's own; its program prints what each returns, the first time and again after a header that only a/Thing.cpp includes has changed and after b/Thing.cpp and b/unit.c have. `registry` is a debug executable of an a/Self.cpp and a b/Self.cpp that register themselves when the program starts, which prints that each did so once. `things` is a static library of a/Thing.cpp, b/Thing.cpp, b/Thing.c and the two unit.c, and `things-app` a program of main.cpp and ../shared/Thing.cpp built on it, which prints what `names` does. `outside` is a static library of one C source that lies outside its configuration's directory and is listed relative to the working directory, built from a working directory with a space in its name; `llvm-ar t` lists its object. ObjectPath asks the rule for the objects of sources without building anything: in the configuration's directory and in directories of it, of one file name in two directories, a .cpp, a .c and a .cu of one name in one directory, outside the directory, and under a directory of the configuration's own that is named objects-outside and holds the whole path of the source outside. No two of them get one object. A path spelled with . and .., a relative source, and a source of a configuration whose path ends in a separator or is ./ are each given the object of the file they lead to, and a .cppm, a .h and a file without an extension are refused. CudaCompile gains a static library of its kernel.cu and a kernel.c beside it, whose archive lists kernel_source.o and kernel_cuda.o. Before the fix SameNamedSources failed at the link of `names`, with duplicate symbols, and of `things-app`, with undefined ones, and its `registry` printed that one of the two sources had registered twice and the other not at all. `outside` built before the fix as well, its object lying in the build directory then: it is there for the path the fix gives that object. |
|||
|
7f8089474b |
fix(build): name a source's object from its path
The object of an implementation unit was named from its file's name alone, <build dir>/<name>_impl.o, and that of a C or CUDA source likewise, <name>_source.o. Two sources of one configuration with the same file name in different directories were therefore compiled into one object, each over the other, with one dependency file between them, and the link was given that object twice (issue #50). A build of an a/Thing.cpp and a b/Thing.cpp that each define a function failed at the link, with duplicate symbols of one of the two and no word of the other. A debug build of two such files that define nothing another file names succeeded, and its program had one file's code twice and the other's not at all. A .c and a .cu of one name shared an object in one directory as well. An object, with its dependency file beside it, is now named from where its source lies: under <build dir>/objects by the source's path from the configuration's directory, objects/a/Thing_impl.o for a/Thing.cpp, or, for a source outside that directory, under <build dir>/objects-outside by its whole path. A .cu's object ends in _cuda.o; a .cpp's still ends in _impl.o and a .c's in _source.o. Two sources then have one object only when their paths are one once . and .. are taken out of them: any other two differ by path or by ending in one of the two directories, and the two directories share nothing, whatever a project calls its own directories. They are directories of their own, and not the build directory itself, because that one holds files named after other things: an interface unit's object, the record of the link and the list of its objects and, for an executable, the BMIs. ObjectPath gives that name, exported beside ExpectedOutput for what looks at an object from outside Build(). Build() names each object by the same rule, once, as it goes over the sources, and the list it keeps of them for the link is what the check whether an object is newer than the output reads as well. Before, each put the name together for itself: Implementation::Check, Implementation::Schedule, and Build() where it compiles C and CUDA sources, lists the link's objects and checks whether to link again. Implementation::Check and Schedule are given the object, where they put its name together from the build directory. The job that compiles a source makes the directory of its object first, since the compiler makes none. The C compile quotes its source, dependency file and object for the shell, as the CUDA compile does: the object of a source outside the configuration's directory holds that source's whole path, and so directories the command did not name before, the working directory's among them where the source is listed relative to it. The progress line of the compile of a .cpp, .c or .cu names the source by the path its object is named from, "Compiling a/Thing.cpp" where it was "Compiling Thing.cpp" for both, and so does the error for a .cu without an nvcc. What else changes: every implementation unit and every C and CUDA source has its object in a new place, so an existing build directory compiles them once more. The objects under the old names stay where they are, unused; a static library's archive does not keep them, being written anew. Interface units are as they were: a BMI is found by its module's name, so two interface files of one name would have to be one module. A source that a configuration lists twice is also as it was, compiled twice into its one object, which the link is given twice. In IncrementalHeaderChange, IncrementalInterfaceChange, StdPcmRebuild and TransitiveInterfaceChange, the lines that spelled out an object's old name take it from ObjectPath. Fixes #50 |
|||
|
0d81aca13f |
test(build): a link of more objects than one argument holds
LinkManyObjects makes a project six directories deep, each with a name of 200 characters, with 120 C sources and a main.cpp that adds up what each of them returns. Every object lies in the project's build directory, so the test first checks that 120 times the length of that directory's path is more than 131,072 bytes. It then builds the sources three ways: as one executable, as a static library and as a shared library, the libraries each with an executable of main.cpp built on it. Each of the three programs prints the sum. It then opens the list the static library's archive step read, builds the library again with one source fewer, and reads what it had opened: the 120 lines of the first build, while the list in its place has the 119 of the second. Before the fix each of the three builds ended with "popen() failed!": the executable's at its link, the other two at the archive step and the link of the library. No list was written, so the test found none to open. |
|||
|
93eca17e57 |
fix(build): give a link its objects in a response file
Build() wrote the path of every object of a configuration into its link or archive command. A command is run by a shell, which is given it as one argument, and Linux holds one argument to 32 pages: 131,072 bytes with pages of 4 KiB, the terminating byte included. Once the objects' paths left the command longer than that, popen started no shell and the build ended with "popen() failed!". Issue #50 notes the limit, and that a response file for the objects would take it away. The step now reads its objects from a file that the command names with @, <output name>.objects in the build directory, one object to a line. clang and llvm-ar both take arguments from such a response file, so the link of an executable or a shared library and the archive step of a static library are handed their objects the same way, and the command is as long for a thousand sources as for one. Build() keeps the objects as a list for that, where it joined their paths into the command as it went over the sources. Each line is quoted for the reader of a response file, which differs from the shell's: it takes a backslash inside quotes to quote the character after it. The file is written before every run of the step, and one that cannot be written fails the build: the list of an earlier build would otherwise stay in its place and the step would read its objects. It is written under a name of its own beside its place and moved there, as the archive of a static library is, so that a step of another crafter-build which reads the list at that moment reads the list it opened, whole, or the new one. The record that decides whether an unchanged build links again held the command, which held the objects. It now holds the command and, under it, the list. The command only names the file, so taking a source out of a configuration can leave the command as it was, with no object newer than the output, as the second build of StaticLibSourceRemoved does: the list is then all that says the step has to run again. |
|||
|
c82b2bb18c |
test(build): a source that leaves a static library leaves its archive
StaticLibSourceRemoved builds a static library and a program on it, on a fresh copy of its fixture outside the checkout. The library has three sources: lib/first.cpp and lib/second.cpp each define Value(), returning 1 and 2, and lib/extra.cpp defines a function nothing calls. It is built three times, by configurations of one name and directory: from the first and the extra source, from the first alone, and from the second in the first's place, as the project of a renamed source lists it. The program prints 1, 1 and 2, and `llvm-ar t` lists the archive's members as first_impl.o and extra_impl.o, then first_impl.o, then second_impl.o. While the second and the third build run, a thread of the test looks for the archive again and again and has to find it every time: the new archive is moved into the place of the old one, where a build that removed the old one first would leave whatever links the library at that moment without it. Before the fix the second build's archive listed first_impl.o and extra_impl.o, and the third's those two and second_impl.o, with a program that printed 1. |
|||
|
2138015178 |
fix(build): write a static library's archive anew
The archive step of a static library ran `llvm-ar rcs` on the archive
the build before had left. `r` adds to an archive that is there: it
replaces the members it is given and keeps every other member as it is.
The object of a source that had left the configuration therefore stayed
in the library, ahead of the members added after it.
The link takes a symbol from the first archive member that defines it.
So after a source of a static library had been renamed, the library
held the object of the file under its old name and, after it, the one
of the file under its new name, and whatever was built on the library
went on linking the first. The object of a source taken out of the
project stayed in the library the same way.
The step now writes its archive under a name of its own, beside the
archive's place, and Build() moves it there once the step has
succeeded, so the archive holds the objects that step lists and no
others. It is moved into place, and the old archive not removed first,
because another crafter-build may be linking against the library at
that moment: a project loaded with GitProject is built in its clone in
the cache, which every project that names the same source shares, and
nothing keeps two crafter-builds from building it at once. llvm-ar put
the new archive in the place of the old one in one step, so such a
link found one of the two, and with the move it still does. A step
that fails leaves the archive of the build before, as it did, and the
next build runs the step again.
build.sh has written the bootstrap's archive anew since
|
|||
|
c929dce8e4 |
docs(packaging): add the 6.4.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 14m4s
6.4.0 lets a project.cpp return several configurations from CrafterBuildConfigurations, which are all built, lets a GitProject or LocalProject spec pick one of a sibling's configurations by name, keeps the Configuration of a project loaded through either of them where its project file built it, and builds a wasm32 library that two configurations of one build share once when its project file sets the target itself. A minor, by the version rule: the notes have New and Fixes and nothing Breaking. |
|||
|
53485c160b |
docs: a project file can return several configurations
The README's opening and the start of "Writing a project.cpp" say that a project file returns one configuration or several, and so does the description in the Flatpak's metainfo. The README has a "Several configurations" section in "Writing a project.cpp": CrafterBuildConfigurations with an example, how the configurations it returns have to be kept, and what a build, test, run, lint, format, -r, install and bundle do with several. "Dependencies" says how a GitProject or LocalProject spec picks one of a sibling's configurations, and that a `#pragma crafter dependency` gets the first; its sentences on the args a sibling gets, on where to make a spec and on IsTopLevelProject() speak of a project file's entry point, where they named CrafterBuildProject. "Dependency notes for agents" says how the dependencyNotes of several configurations combine, and which runs leave AGENTS.md alone now that a list of configurations can be refused before a build starts: its sentence on that said that a build that fails still has the notes, and named an `install` or `bundle` refused before building as the one refusal that writes none. The table of ScriptContext says that a script's `project` is the configuration it is declared on. |
|||
|
5795b666f5 |
test: several configurations from one project file
BuildAll builds configurations the test makes itself, on a fresh copy of its fixture outside the checkout. A library, a program built on it and an unrelated program all come out built, each in the record of the pass under its PcmDir, and a list that names one configuration twice builds it from nothing, what the build before left of it being removed first, and leaves it in the record of the pass once. A library built on another library of its own name, path and type, so that the two are built into one directory, builds, with both archives in that directory; returned beside a program that is built on it, the pair is refused, both by name, before the program is built or anything is recorded. Two libraries that are each built on a configuration of the other's directory are refused by name, and nothing of them is built or recorded. A wasm32 library that names no sysroot and a program for the host built on it leave the library in the record once, under the directory it has after the pass, and its refusal comes back once; it is refused for its -fno-exceptions, so the case needs no WASI sysroot. Of two programs built on a library that does not compile and a third that has nothing to do with it, the third is built, the two are not, and the library's error comes back once. Two configurations that would be built into one directory are refused, and neither is built. With a wasm executable that declares a variant among them, a program of one source is linked no earlier than the program and library given before it; the wasm one is refused for its -fno-exceptions before it builds anything, so the case needs no WASI sysroot. ProjectConfigurations loads fixture project files staged outside the checkout. A file with CrafterBuildConfigurations comes back as the three configurations it returns, with the pointer the file took from the second to the first intact, and as two when its args say so; LoadProject refuses it. A file with CrafterBuildProject comes back as a list of one whose test still depends on that Configuration, and that test builds and passes. A file with both entry points, one with neither, and ones whose CrafterBuildConfigurations returns nothing, a null pointer or one configuration twice are refused, each with a message that says which. Then crafter-build's verbs, through Run() and RunTests, on the file of three: a build builds all three; -r refuses to pick between its two executables, and runs the one executable there is when the file returns two configurations; RunTests runs the tests of the first and the third configuration in one run, and when the first declares the third's test as well, that test fails for both, naming the two, and is not built, while the first's own test passes, and a list that names the first configuration twice runs its test once; with a fourth configuration of the third's name and path, a test run and a build are each refused for the two that would be built into one directory, and neither writes the AGENTS.md that a build which is not refused writes from the template the test puts beside the project file; `run` reaches a script of the first and of the third configuration and hands each the configuration that declares it; install refuses the project while none of the three is packaged, bundle refuses it when two are, and with one packaged executable beside the library bundle does not take the library for the app. SiblingConfigurations loads such a file as another project's sibling. A spec without `configuration` gets the first, a spec that names one gets that one, and the three specs share one load: the dependency of the second is the first as LocalProject returned it. All three are rebased onto the sibling's directory. A name the sibling does not have throws with the names it has, and a name that two configurations of another fixture share throws too, while a spec without a name still gets the first of those two. Building the second builds the first with it and leaves the third unbuilt. A file that returns something a sibling keeps to itself is refused when it is loaded, the configuration and the sibling named: the library the sibling's program is built on, the configuration of that program's test, and a helper only that test is built on, none of which the sibling's file returns. A project that returns the sibling's third configuration beside one of its own builds both, cannot run the sibling's script and runs its own, and its test run leaves the sibling's test alone. DependencyNotes gains a project of two configurations and a fixture, outer, that builds against lib: two Direct configurations give what each of them names; a project a Direct one names is followed when a Transitive one leads to it; a configuration under None keeps out what only it is built against; with both under None, AGENTS.md is the template's text; and a returned configuration of another project is one of the projects the notes come from, followed further only under Transitive, which is also what a file that made no configuration gets. For outer's own AGENTS.md, written from the Configuration LocalProject returned and outer's project file, outer's own setting selects: lib under Direct, lib and base under Transitive, nothing under None. Script runs a script of each of two configurations, each handed the configuration that declares it, refuses a name both declare without running anything, and, given a list that names one configuration twice, runs the script asked for, which a name declared twice would have kept it from. Lint formats the sources of two configurations in one run, counts a rule both register as one, and runs a rule only one of them registers over the sources of both. Of two returned configurations that register a rule under one name the earlier one's runs, over the sources of all three, though the configuration returned ahead of both depends on the later one. |
|||
|
4283a3ecd2 |
feat: let a project file return several configurations
A project.cpp described one configuration: CrafterBuildProject returns a Configuration by value, and anything else the project wanted built had to be among that one's dependencies. There it was built as part of that configuration's graph: under the check that a graph builds each module once, with its libraries handed up to whatever links that configuration, and with its tests and scripts out of reach of `test` and `run`. Jorijn asked for a project.cpp that can return several unrelated configurations which all get built, and suggested a separate entry point, so that no existing project file breaks. A project file now defines one of two functions. CrafterBuildProject is as it was. CrafterBuildConfigurations returns std::vector<Configuration*>: pointers to configurations the file keeps alive itself, or that GitProject and LocalProject gave it. The two have different names because the loader finds the entry point by its C symbol, which carries no return type, so one name with two return types would be called as whichever the loader guessed. They are pointers because a project file takes pointers between its configurations, for `dependencies` and for a test's, before it returns them, and a vector of values would move them. LoadConfigurations loads a project file with either entry point and returns the list. A CrafterBuildProject's Configuration comes back as a list of one, constructed by the call where the loader keeps it for the rest of the process; LoadProjectFromRoot, which did that for a sibling's, leaves it to LoadConfigurations, and the project cache holds the lists without owning a Configuration. The Configuration of the project crafter-build is pointed at is kept that long as well, where it was a local of Run(). LoadConfigurations throws for a file that defines both functions or neither, and for a CrafterBuildConfigurations that returns nothing, a null pointer or one configuration twice. It also throws for one that returns a configuration a project loaded through GitProject or LocalProject keeps to itself, which the loader now takes down when it loads that project's file: what the configurations the file returned led to through `dependencies` or through their tests, as far as the first configuration on each way that a loaded project's file had returned or another loaded project keeps. Returned from here, such a configuration would count as this file's own to `test` and `run`, and only the configurations a project file returns are rebased onto its directory. LoadProject stays, for a caller that wants a CrafterBuildProject's Configuration by value, and throws for a file with the other entry point. GitProject and LocalProject keep, per spec and args, the list a sibling's file returned, and return the first one unless the spec's new `configuration` names another by Configuration::name. Every configuration of the list is rebased onto the sibling's directory, except one that another project's file had returned before, which was rebased onto that project's. Specs that differ only in the name they pick share one load. A name the sibling does not have throws, listing the names it has, and a name two of its configurations share throws too. A `#pragma crafter dependency` gets the first. BuildAll builds the returned configurations in one pass. Each is built by Build(), as a project's one configuration is, the first on the calling thread and each other one on a thread of its own, and its result then goes into the record of the pass under its PcmDir, where Build() looks for a dependency. One that another of them is built on is built before that other starts, which then finds it in the record: started beside it, the other would not find it there yet and would build it a second time. A configuration is not put into the record before it is built, because a dependency of its own that is built into the same directory would be handed its unfinished build and wait for it, while it waits for the dependency. All of them are built to the end, and the errors come back in the order given, each message once; an exception a build throws comes back as an error that names the configuration, where Run() printed the exception's own text for a project's one configuration. Refused before anything is built: two that would be built into one directory, which would be two builds writing the same files at once; several that are each built on something of another's directory, so that none could be built first; and one that is built on something of its own directory when another is built on that directory as well, since the record holds one result for a directory and the other could be given either. One shortcut is in it. A wasm executable that declares wasmVariants builds what it is built on once more per variant, and says which variant by rewriting those configurations in place, at the end of its Build(). A library that two returned configurations share would change under the one still building its baseline, so with such an executable anywhere in the graph BuildAll builds the configurations one after the other, on the calling thread. Keeping them side by side takes a variant driver that does not rewrite configurations other builds read, which this commit does not attempt. Run() works on the list. A build builds all of it. `test` runs the tests, and `run` offers the scripts, of the ones in it that the project file made itself. One that another project's file returned to GitProject or LocalProject, and that this file returns in turn, is built with the rest, but its tests and scripts stay that project's, so `run` still reaches only the scripts of the project crafter-build was pointed at. What the list itself rules out Run() refuses once the project file has loaded, before any of the list is built and before AGENTS.md is written: for a build, `-r`, `install` and `bundle` whatever BuildAll refuses a list for, and for `test`, which builds its tests with Build() and never comes to BuildAll, two returned configurations of one directory. BuildAll makes its refusals again for whoever calls it. A script is handed the configuration it is declared on. `lint` and `format` walk from every returned configuration and keep, as before, the configurations in the project's directory: the returned ones first, in the order the file returned them, then what they depend on, so that of two returned ones that register a rule under one name the earlier one's runs. `-r` runs the executable when exactly one of them is one, and `install` and `bundle` export the one that is packaged as a Flatpak; with more than one candidate each refuses and names them, `-r` once everything is built and `install` and `bundle` before anything is. AGENTS.md takes the notes that the dependencyNotes of each returned configuration the file made itself selects among what that one is built against, and the file's pragma tooling and a returned configuration of another project go by the widest of those settings. There, a configuration is another project's when GitProject or LocalProject loaded it from another project file than the one whose AGENTS.md is written, two files being one when they resolve to one path, so UpdateAgentsMd still reads the setting of a Configuration one of the two returned when it is given that Configuration's own project file. For that, RunTests, RunLint, RunScript and UpdateAgentsMd each gained an overload that takes the list, and the one that takes a single Configuration calls it with a list of one. SetParentProject gained one too, and ParentLib searches the graph of every configuration it was given. BuildAll, RunTests and RunScript count a configuration the list names twice once. The tests of several configurations share what one configuration's had to itself: AddTest names a test's sources, tests/<name>, and its build directory after the test and its compile state, not after the configuration that declares it. Two configurations that each declare a test of one name, compiled alike, would have RunTests build both in that one directory, each with the dependencies of its own declaration. RunTests fails both without building either, and each failure names the configurations. It compares tests of different configurations only, so a project of one configuration is treated as it was. The --help text names the second entry point, says what -r, install and bundle do with several configurations, and speaks of the project file's entry point as what gets the project args, where it named CrafterBuildProject. AGENTS.template.md says that a project.cpp returns one configuration or several, that Run() works on the list and what a new verb has to decide about it, which configurations have their path rebased, and that the scripts of a returned configuration of another project cannot be run. Two of its notes named LoadProject as what loads a project.cpp for crafter-build, which Run(), GitProject and LocalProject no longer call, and speak of the load now. Its rule for the link flags of a test that loads a project file names the ways a test loads one, where it named LoadProject, and its entry for `:Script` speaks of the `scripts` of the configurations the driver is given, where it named `cfg.scripts`. Its entry for `:Platform` names LoadConfigurations beside LoadProject. That entry also said that `:Platform` holds all OS-specific code, which it did not before this range either, :Agents, :Progress, :Lint and :Clang including POSIX headers of their own, and no longer says so. The bug-prover lens's section names BuildAll's threads and LoadConfigurations. Not in this commit: a way to say which executable -r runs or which app install and bundle export when there are several, and a keyword that lets a `#pragma crafter dependency` name a configuration. |
|||
|
a7aa22220b |
test(wasm): a configuration is the same with its WASI sysroot named or not
WasmSysrootKey makes two wasm32 configurations that differ in one thing: one names no sysroot and the other names the toolchain's WASI sysroot. They have to be one configuration: the same VariantId, PcmDir and BuildDir, the same std module key, and the same compile command, which names the WASI sysroot. A third, with a sysroot of its own, has another VariantId. It then builds two programs for the host in one pass, each on the same wasm32 library, which names no sysroot. The library carries -fno-exceptions, which a wasm build is refused for before it makes a directory, so the case does not depend on the machine having a WASI sysroot. The library's PcmDir has to be the same after the first program's build as before it, and the pass has to hold the library once. Against the engine as it was before the fix the test fails on each of the three: the two configurations have different VariantIds, the library's PcmDir changes with the first build, and the pass holds the library twice. |
|||
|
1ddba745cf |
fix(wasm): resolve the WASI sysroot where it is read, not in Build()
A wasm32 configuration that names no sysroot is built against the toolchain's WASI sysroot. ApplyStandardArgs stores that sysroot in cfg.sysroot, for a project file that calls it. For a configuration whose project file sets the target itself, Build() stored it on its way in. VariantId hashes the sysroot, so such a configuration had one BuildDir, BinDir and PcmDir until its build started and others from then on. A build pass records each dependency's build under its PcmDir, and a configuration asks for a dependency by the PcmDir it has at that moment. A wasm32 library that two configurations of one pass are built on was recorded under the first directory for the one that asked first. One that asked after the library's build had started asked under the second directory, found nothing there, and built the library again. Configuration::ResolvedSysroot now gives what cfg.sysroot comes to: the toolchain's WASI sysroot for a wasm32 configuration that names none, cfg.sysroot as it stands for every other, as ResolvedPackaging gives what `packaging` comes to. VariantId, the std module's flags, key and source, the compile and link commands and the check that refuses a wasm build without a usable sysroot read it, and Build() no longer stores the sysroot in the configuration. ApplyStandardArgs still does: what a project file reads in cfg.sysroot after the call stays what it was. The directories a build writes keep their names: a configuration that named no sysroot was built into the ones its VariantId named once Build() had stored it, which are the ones it names now. StdPcmFlags takes the toolchain, as StdPcmKey does, so that a VariantId asked for under a toolchain resolves the sysroot under that one. |
|||
|
1440e20231 |
test(external): a sibling's pointers to its own Configuration hold
SiblingOwnPointers loads a fixture through LocalProject, on a fresh copy
outside the checkout: a library whose project file declares a test with
cfg.AddTest("OwnTest").Dependencies({ &cfg }). The one dependency of
that test has to be the Configuration LocalProject returns. The test
reads the dependency out of that Configuration and compares the two
addresses, without following the dependency.
Against the loader as it was before the fix the test fails: the
dependency is not that Configuration.
|
|||
|
8baf14068e |
fix(external): keep a sibling project's Configuration where it was built
A project file may take pointers to the Configuration it returns. The
usual one belongs to a test that links the library the file describes,
cfg.AddTest("T").Dependencies({ &cfg }): where the compiler constructs
the local the file returns in place of the return value, &cfg is the
address of what CrafterBuildProject returns.
For the project crafter-build is pointed at, that address stays good:
Run() initialises its Configuration with the call. For a project loaded
through GitProject or LocalProject it did not. LoadProjectFromRoot
assigned the call's result to a local, and from there the Configuration
was moved into the project cache, so what a consumer got was not the
object the project file had built, and every pointer the file had taken
to that one pointed at an object that no longer existed. RunLint follows
such a pointer: for a sibling whose path lies inside the project's
directory it works out the compile command of each of the sibling's
tests when a rule needs an AST, and GetCompileCommand walks the
dependencies of the configuration it is given.
LoadProjectFromRoot now makes the Configuration on the heap with the
call as its initialiser, and StoreProject takes the unique_ptr, so the
Configuration is constructed where the cache keeps it and is never
moved.
|
|||
|
12e8b908f6 |
docs(packaging): add the 6.3.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 15m13s
6.3.0 holds a build to as many steps at once as the machine has hardware threads, where every stale shader, asset to compress, C, CUDA and C++ unit got a thread of its own and nothing bounded how many ran at once. It makes the object of a module interface unit that an earlier build left with its BMI alone, or with the object of before an edit, and it refuses interface units of one configuration that import each other, whose first build hung. A minor, by the version rule: the notes have New and Fixes and nothing Breaking, and Jorijn's "6.3.0, that's internal and not user facing" settled it. What he was asked about: the range takes Compile() off Module, ModulePartition and Implementation, and the `compiled` flag off the first two, all of which interfaces/ exports. They are what Build() itself compiled a unit with, and none of the 35 project.cpp files of this checkout and the ones beside it reads the flag or calls Compile(). |
|||
|
621438de5f |
docs: say how many steps a build runs at once
The README says in "Writing a project.cpp" that a build runs at most as many of its steps at once as the machine has hardware threads, which steps those are, and that an ExternalDependency's CMake build and the tests are not among them. Under Tests, --jobs= is named as what counts the tests, and --jobs=1 as one test at a time where it said "serial mode": the steps of that one test's build still run side by side. |
|||
|
f9d0ec24fe |
test(incremental): an interface unit without its object is built again
IncrementalInterfaceObject builds a module with a partition and a
program that prints what the module's function returns, without
optimisation, so that what it prints says which object was linked. It
edits the primary interface, builds, and puts the object of before the
edit back dated two seconds before the new BMI. A build with the
program still there has to make the object again and link the program
again; after the old object is put back once more and the program
deleted, a build has to make the object again and the program print the
edited value. Then it deletes both objects and the program and builds:
both objects have to be back. A last build of the intact tree has to
leave the objects as they are.
On
|
|||
|
6087ce81db |
test(build): build many units at once and count the threads it takes
JobLimit makes two projects and one more for every 32 hardware threads
and builds them from nothing at once, each from a thread of its own, as
RunTests builds its tests, while it counts the threads of its own
process. A project is 69 sources: 64 that import nothing, half C and
half C++, then a module of two partitions, one importing the other,
with its implementation unit, and a main.cpp that imports the module.
It is the same size on every machine, so that no command of its build
grows with the machine. The builds together may add as many threads as
the machine has hardware threads, and have to add at least two where
there are two; every program is then run and has to print 995: what
its 64 C and C++ functions return and the module's Top(), which is
built on the two partitions' functions. On
|
|||
|
913310da86 |
feat(build): run a build's steps on one worker per hardware thread
Build() started a thread for every stale shader, asset, C, CUDA and C++
unit, and Module::Compile one more for every stale partition, and
nothing bounded how many of them ran their step at once. Jorijn asked
for the amount of parallelism to be limited by the amount of threads
instead of just starting one per file; the threads are taken here to be
the machine's hardware threads.
The new :Jobs partition holds the two pieces. JobPool is worker threads
behind one queue, started as jobs need them up to a fixed number, and
JobPool::Process() is the pool of the process: at most a worker per
hardware thread, one where std:🧵:hardware_concurrency does not
know. JobGroup is the jobs of one build on a pool. A job starts once
the jobs it was added after have finished; the first job to fail keeps
the ones that have not started from starting, and Wait() returns its
error. No job waits for another job, and a JobGroup made on a worker of
its own pool throws: a worker that waited for a job still in the queue
would hold the thread that job needs.
Build() adds what it did on those threads to a JobGroup instead, and
the group's first error replaces the buildCancelled and buildError pair
the threads set. The module units no longer block on the `compiled`
flag of the units they import: Schedule() replaces Compile() on Module,
ModulePartition and Implementation and adds a unit's jobs after the jobs
that write the BMIs it imports. An interface unit is two jobs, its BMI
and then its object from the BMI, so the units importing it start when
the first is done, as they did when one thread ran both commands and
raised the flag in between. A primary interface now waits for the BMIs
of its partitions and no longer for their objects. Each of the two jobs
has a progress line, "Precompiling X.cppm" and "Compiling X.cppm" for
every interface unit, where a module and its partitions shared one
"Compiling interface X".
RunBuildCommand runs its command on a worker of the process's pool: on
the calling thread when that is one, otherwise it waits for one. A link,
an archive, the std module's precompile and project.cpp's compile are
steps under the limit that way. The threads Build() starts per
dependency and per external dependency stay: one of the first runs the
dependency's own Build(), or waits for the thread that does, and one of
the second runs git and cmake.
With the BMI and the object as two jobs, a build that fails between them
has written the BMI and skips the object, and Check, which reads
staleness off the BMI, would call the unit built from then on.
Schedule() therefore adds the object job alone for a unit whose BMI is
up to date and whose object is missing or older than the BMI. A build
interrupted between the two commands, or one whose second command
failed, left the same behind before, and it stayed: the link took the
object of the source before the edit, or failed on the missing one.
ImportCycleError is now what keeps Schedule() from following a round of
imports without end.
The limit is on steps. Outside it, as AGENTS.template.md lists: an
ExternalDependency's cmake --build, which keeps its own --parallel of
as many jobs as there are hardware threads; the tests RunTests runs,
--jobs= of them at once as before; the Crafter.Build modules
EnsureCrafterBuildPcms precompiles one after another; and the threads a
step starts for itself, which lld does for a link and Crafter.Asset's
GDeflate compressor for an asset. The pool is one process's. The --help
text says what a build runs at once and that test --jobs= counts tests.
ConcurrentDependencyReset read the `compiled` flag, which is gone. It
asserts on `checked` and `scheduled` instead, the state a reset from
another build's thread would clear now, with a unit scheduled twice as
the result, and the comment in its fixture says what the implementation
unit comes after now. TransitiveInterfaceChange's comment names
Schedule() where it named Compile() as what honours a partition's
imports. Two comments in :Platform that spoke of worker threads, a word
that now means the pool's, name the threads they mean. The bug-prover
lens's section said shaders compile on a thread of their own each, and
describes the pool now.
|
|||
|
eff9868b68 |
docs: interface units that import each other stop the build
The README says in "Writing a project.cpp" that a unit is built after the modules and partitions it imports, that interface units of one configuration that import each other are refused with an error naming them, and that the imports are read from the source text without compiling it, so one in a string literal, in a comment that spans lines or under #if 0 counts too and can make such a round in a project the compiler accepts. |
|||
|
ee331377a4 |
test(build): interface units that import each other are refused
ImportCycle builds three fixtures as static libraries, each on a fresh copy outside the checkout: two partitions that import each other, a partition that imports its own module, and two modules that import each other. Each build has to return an error that holds its round, "Ring:First -> Ring:Second -> Ring:First", "Own -> Own:Part -> Own" and "East -> West -> East", and leave neither a build nor a bin directory. Before the refusal the test ran into its timeout: the first of those builds never returned. |
|||
|
e87dc4f015 |
fix(build): refuse interface units that import each other
Two partitions that import each other, a partition that imports its own module, and two modules of one configuration that import each other cannot be built in any order. Build() compiles each stale unit on a thread that first waits for the units its unit imports, and a primary interface waits for every stale partition of its module as well, so a build that found every unit of such a round stale, as a first build of them does, hung: every thread waiting, no compiler running, no error. ImportCycleError follows the imports of a configuration's interface units at the top of that configuration's Build(), before it makes a directory or builds a dependency, and Build() returns an error naming the units of the first round it finds in the order they wait in, "Ring:First -> Ring:Second -> Ring:First". A primary interface counts as coming after each partition of its module, whether it imports that one or not, since that is how it is built. A configuration built on the one refused has started its own build by then: the check reads the imports ResolvePendingImports has just placed, which are that Build()'s to read while it runs. The imports are the ones the source scanner reads, and it reads one in a string literal, in a comment that spans lines or under #if 0 as it reads any other (issue #45), so the units the error names are where to look for one of those too. The error says so, since the compiler sees no round in such a project, and AGENTS.template.md has it under Gotchas. |
|||
|
5b75df3b19 |
docs(packaging): add the 6.2.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 14m29s
6.2.0 makes CUDA sources compile in the Flatpak: crafter-build finds nvcc itself, under CUDA_PATH, /opt/cuda or the host's /usr/local/cuda, or in an absolute entry of PATH, where it used to run whatever the sandbox's PATH gave, which never holds the host's toolkit, and it links that toolkit's static CUDA runtime itself where the toolkit's lib64 holds it. The GPU architecture CUDA sources compile for is configurable and native by default, and a .cu compiles again when a header it includes changes. A minor, by the version rule: the notes have New and Fixes and nothing Breaking, and Jorijn's "6.2.0 is fine" settled it. The default architecture moves from sm_89, which carries its PTX, to native, which carries none, so a program built for native has no PTX for a GPU of a newer architecture. That is under New rather than Breaking because no Flatpak release compiled a .cu with the PATH its manifest sets: each ran a bare nvcc in the sandbox, whose PATH, /app/bin:/usr/bin, holds no toolkit, so a project had to set another PATH itself to compile one. A program for other machines takes another architecture, such as --cuda-arch=all-major, as the notes say. A project that names -lcudart in cfg.linkFlags keeps building, with its shared runtime first on the link line. VariantId changes for no configuration without CUDA sources but one built with --cuda-arch=, which was a project argument and is crafter-build's own now; a configuration with CUDA sources builds once in new bin/ and build/ directories, keyed by its architecture, for native by crafter-build's reading of the machine's GPUs, and by its nvcc. |
|||
|
df79dcd46d |
docs: a CUDA section in the README
cfg.cuda had no section of its own, only mentions in passing. The new one says how sources are listed and linked, where the toolkit is found and what the Flatpak sees of it, what cfg.cudaArch picks, and what nvcc is not given: the include paths, defines and compile flags of the C and C++ compiles, and -g. The Flatpak output section's advice for other machines names a --cuda-arch= other than native, such as all-major, beside --march=x86-64-v3. |
|||
|
99653194ba |
test(cuda): build a .cu without link flags, and through a library
CudaCompile's builds name no CUDA library now, but for the last. The toolkit it names through CUDA_PATH has a lib64 beside its nvcc with the real toolkit's libcudart_static.a, so the executable links only if crafter-build links the runtime, and the recorded link names that archive. Another build puts the .cu in a static library and the C++ unit in an executable built on it, which links only if the library hands the runtime on. That lib64 also holds a libcheckpoint.so and a libm.so that are no libraries, as Arch's lib64 holds a real libcheckpoint.so and a libOpenCL.so: another build links an executable with CUDA sources on a library of the project's named checkpoint, and clang++ adds -lm to every C++ link, so a link that searched the toolkit's lib64 would stop on one of them wherever its -L stood. The last names -L<lib64> -lcudart, as a project with CUDA sources had to, and has that -lcudart ahead of the static archive, so the shared runtime is the one the linker takes. The test skips where the real toolkit's lib64 holds no static runtime, since crafter-build then links none. Before crafter-build linked the runtime, the link failed on an undefined CUDA runtime symbol. ToolchainResolve checks where the runtime is looked for, on staged toolkits, so that it runs in CI: the archive in the lib64 beside nvcc's bin, none where that lib64 holds none, none where it links to itself, which a look that threw would have stopped the test on, and none without an nvcc. CudaCompile is the only check of the runtime link itself, and it skips without such a toolkit, so AGENTS.template.md's note on when to run it names the link as well as the compile, and gives the lookup to ToolchainResolve. |
|||
|
22ea97406d |
feat(cuda): link the CUDA runtime of the toolkit that compiles the .cu
A program with CUDA sources needs the CUDA runtime, which cfg.linkFlags had to name: -L/opt/cuda/lib64 -lcudart for Arch's toolkit, a path into it. In the Flatpak that holds for /opt/cuda but not for the host's /usr/local/cuda, which is under /run/host there, at a path crafter-build resolves for nvcc and a project.cpp does not know. Jorijn chose to have crafter-build link it. A configuration with CUDA sources links the static runtime of the toolkit whose nvcc compiles them, by its path, with the -lrt -lpthread -ldl that nvcc's own link line puts after it. ResolveToolchain finds it with nvcc, as Toolchain::cudaRuntime: libcudart_static.a in the lib64 beside nvcc's bin, looked for without starting a process, so a test can stage a toolkit for it as for nvcc, and crafter-build --version prints it. The static one, so no run path into the toolkit ends up in the program; libcuda.so.1, which the runtime loads, comes with the driver. By its path, not through a -L of the lib64, which would put the toolkit's libraries, such as Arch's libcheckpoint.so, in the way of a project's own of the same name. It goes into BuildResult::runtimeLibs, which a configuration hands its consumers as it does libs and every link puts after them, so whatever is built on a library with CUDA sources links the runtime too, and a -lcudart a project names itself comes first. Where that lib64 holds none, as where a distribution keeps the toolkit's libraries in its own directories, cudaRuntime is empty and nothing is linked, as before: a -lcudart_static the linker could not find would fail the link even of a project that names its own -lcudart. The archive is looked for without throwing, so a lib64 that cannot be looked into, through a link loop or for want of permission, counts as one without it. |
|||
|
6b2da3b1d6 |
test(cuda): a changed header compiles the .cu again
CudaCompile's .cu includes a header of its own now. After the unchanged build, the test makes the header newer than the object and builds once more, which has to run nvcc again. Before nvcc wrote a depfile, it did not, and the object built from the old header stayed. |
|||
|
c2338d1122 |
fix(cuda): rebuild a .cu when a header it includes changes
A .cu was compiled again only when it was newer than its object, so one whose header changed kept the object built from the old header. The C and C++ paths ask the compiler for a depfile and check every prerequisite in it; nvcc was left out because its -MD and -MF had never been run here. They work with CUDA 13.4 as they do with clang: the depfile lists the .cu and every header it read, the toolkit's and the system's included. nvcc puts a space before the rule's colon, which NewestPrerequisite reads as a target token like any other. An object from before has no depfile and is compiled once more. |
|||
|
ad021ee652 |
test(cuda): build a .cu with the toolkit CUDA_PATH names, and with none
CudaCompile puts an nvcc on PATH that fails, names a toolkit through CUDA_PATH whose nvcc writes down its arguments and runs the real one, and builds an executable from a C++ unit and a .cu: with the default architecture, then with another one, which compiles the unchanged .cu again in a directory of its own, then with nothing changed, which compiles nothing. With the bare "nvcc" of before, the first build runs the nvcc on PATH and fails. It needs a real toolkit, which it looks for as crafter-build does, with ResolveToolchain and the inputs GetToolchain() gives it, and it skips without one. Nothing in CI installs one, so AGENTS.template.md says to run it in the native loop. CudaMissing needs none, so CI runs it: with CUDA_PATH naming an empty directory, a build with a .cu fails with "cannot compile kernel.cu: no nvcc at <directory>/bin/nvcc (CUDA_PATH)", and a build without CUDA sources in the same process still succeeds. With the bare "nvcc" of before, that build ran whatever nvcc PATH held, and where PATH held none, as in the Flatpak, failed with "sh: line 1: nvcc: command not found". AGENTS.template.md names it beside CudaCompile. |
|||
|
967dd12b06 |
feat(cuda): make the GPU architecture configurable, native by default
nvcc ran with -arch=sm_89 for every build, which is code for that one architecture and its PTX, whatever GPU the program was for. Jorijn asked for the architecture to be configurable, and native when nothing sets it, as the CPU's is. cfg.cudaArch is nvcc's -arch now, and it defaults to "native": nvcc compiles for the GPUs it sees, and where it sees none it warns and uses its own default architecture. Like -march=native it is for a program that runs where it is built, since it carries no PTX, and `crafter-build bundle` warns of a bundle whose CUDA code, in the program or a library it is built on, is compiled for native, as it warns of -march=native. ApplyStandardArgs sets it from --cuda-arch= and CRAFTER_BUILD_CUDA_ARCH as it sets march from --march= and CRAFTER_BUILD_MARCH; AddTest and AddMarchVariants give their tests the parent's, as they give them its sysroot and debug flag; and ForceHostTooling gives host tooling the host's, as it gives it the host's march, since project.so runs it on the machine that loads it. A .cu is compiled again only when it is newer than its object, so the architecture keys VariantId, and so does the nvcc that compiles it, by what it is rather than where: Toolchain::nvccStamp, its canonical path, size and time, read without a process, changes when CUDA_PATH names another toolkit and when an update replaces the one at the same path, as a package does at /opt/cuda. native is keyed as well, by Toolchain::cudaNativeKey: the NVIDIA display devices sysfs lists, by PCI address and device ID, and CUDA_VISIBLE_DEVICES and CUDA_DEVICE_ORDER, which choose and number them, each empty value apart from an unset one, read without a process. It is crafter-build's reading of the machine, not nvcc's. The word alone would keep an object compiled for a GPU the machine no longer has, after a GPU change or on another machine that shares the checkout, and that object carries no PTX for the GPU it has now, where sm_89's carried its PTX. Only a configuration with CUDA sources is keyed, so every other one keeps the directory it had, but for one built with --cuda-arch=, which was a project argument, hashed as one, and is crafter-build's own now. |
|||
|
2fd45133a0 |
test(cuda): resolve nvcc on staged toolkits
ToolchainResolve stages toolkit roots, a PATH and a host root, and checks the order (CUDA_PATH, then the roots, then PATH), that a CUDA_PATH without an nvcc is an error and not a fallback, that a relative one names an absolute nvcc, that a file that cannot be run is no nvcc and a relative PATH entry no place to look, what the error says when there is none, and that a toolkit resolves under the host root through a link: /usr/local/cuda in the host's /usr to an absolute path, named with a trailing slash too, through /etc/alternatives and to a relative path, and a link outside the host's /usr that leads into it. A link to itself finds nothing. |
|||
|
fdba70d176 |
fix(cuda): look for nvcc instead of leaving it to PATH
cfg.cuda compiled with a bare "nvcc", which the shell looked up on PATH. In crafter-build's Flatpak PATH is /app/bin:/usr/bin, as its manifest sets it, which never holds the host's toolkit, so with it every build with CUDA sources stopped at "sh: line 1: nvcc: command not found", although the sandbox sees /opt/cuda through --filesystem=host. ResolveToolchain now finds nvcc as it finds clang++: CUDA_PATH, which is exclusive as CRAFTER_BUILD_LLVM_DIR is, else /opt/cuda (Arch's package) or /usr/local/cuda (NVIDIA's installer and packages), else the absolute entries of PATH, which it searches itself so that a build without a toolkit can say where it looked. A relative CUDA_PATH is made absolute there, once, as CRAFTER_MINGW_DIR is, since nvcc runs later from whatever working directory a build is in. The sandbox shows the host's /usr and /etc under /run/host, with its own runtime at /usr, and NVIDIA's /usr/local/cuda is a link, to /usr/local/cuda-<version> or through /etc/alternatives. A link to an absolute path names a path of the host, /opt/cuda pointing at /usr/local/cuda-<version> too, and the sandbox would look it up in its own root, so where the path of a toolkit, CUDA_PATH, /opt/cuda or /usr/local/cuda, is such a link, HostPath follows it, and the link its target is in turn, each taken as the host's; a link partway along that path, or inside the toolkit, is the kernel's to resolve, in the sandbox's root. A missing toolkit is reported by the build that has a .cu to compile and not by GetToolchain(), so no other build fails for want of one. crafter-build --version prints the nvcc it found, whether or not the compiler could be resolved. |
|||
|
ff3cc20e70 |
docs(packaging): add the 6.1.0 release entry
All checks were successful
Flatpak / flatpak (push) Successful in 13m51s
6.1.0 lets a program crafter-build builds run outside its sandbox: an executable can be packaged as a Flatpak of its own, installed with `crafter-build install` or bundled into a file with `crafter-build bundle`, with flatpak-builder modules and data under /app/share where it needs them. The Flatpak gains the org.freedesktop.Flatpak permission those two verbs run the host's flatpak with. It also fixes programs built on a shared library on Linux, which did not start, compiles that took headers from what a build left in a dependency's bin/ or build/, `format --check format`, which rewrote the sources, and wasm tests declared with AddTest, which never ran. A minor, by the version rule: the notes have New and Fixes and nothing Breaking. Default still builds an executable as linked, and VariantId and the bin/ layout change for nothing that is not packaged as a Flatpak, but for a build given --packaging=, which moves to other bin/ and build/ directories: the argument was a project arg, hashed into VariantId, and is a standard arg now, for dependencies too. `install`, `bundle` and `--packaging=` were project args until this range made them two verbs and a standard arg, and no sibling project.cpp reads any of them: the only `install` in one is the name of a `run` script, which `run` takes before any verb. `test test`, `lint lint` and `format format` now take the second word as a glob. The include walk leaves out every directory named bin or build now, and that is under Fixes rather than Breaking: those are the names crafter-build gives what it writes, and in the Crafter repositories and the dependencies crafter-build has cloned, the one #include that needs a header found only there is glslang's, in a source its own CMake build compiles, not crafter-build. The permission is listed under New, and `flatpak update` lists it before it asks to proceed. |
|||
|
79b24a93b8 |
docs: cfg.flatpak.share in the README
The README's Flatpak section shows share entries in its picture of the bin directory and in the cfg.flatpak example, and says what they are for, that files/share is kept to what is listed, that the ../share lookup works under -r as well, that flatpak exports what it exports of them by its own rules, and what build-export checks of that, that an entry may not take a field's file, that the app's desktop entry is checked whichever placed it, and which directories an entry may not copy: those that hold what the build writes or lie in it. AGENTS.template.md lists them among what FlatpakApp holds. |
|||
|
e0ac8ee600 |
feat: install a Flatpak's data under /app/share
A program packaged as a Flatpak could only have its files beside it in files/bin, where cfg.files goes. One that finds its data at <its directory>/../share/<name>, as Crafter.Review finds its process/ directory, had no way to get it there: files/share belongs to the writer, which removes anything it did not put there, and a module of flatpak-builder's would have placed it only in the installed app, never under -r. cfg.flatpak.share lists files and directories of the project and the path under /app/share each goes to. The writer copies them into files/share with the desktop entry, metainfo and icons, keeps them while they are listed and removes them once they are not, as it does those. -r runs the program from files/bin, so the same ../share lookup finds them there. What is exported of them is flatpak build-finish's to decide, by its own rules, as for any app's files: the app's D-Bus services, MIME types, search providers and KRunner plugins, which have no field of their own, are placed like any other file. A library's are not passed on to the programs built on it, since data a library needs at run time already goes through cfg.files. A dependency that packages its own executable has the sources rebased by the loader, as its cfg.files are. Share entries change files/share and not what is compiled, so they are not keyed into VariantId, which its test checks. Every file bound for files/share, the desktop entry, metainfo and icons included, now goes through one placement check, which refuses two files for one path, a field's file among them, and a file where another needs a directory, naming both. A target that is absolute or leaves share/ is refused too. Any other place is open to a share entry, a second desktop entry, an add-on's metainfo and any icon included, as for any app's files: flatpak build-export refuses an exported icon that is not a square image and a D-Bus service that is not a key file, warns of the app's own desktop entry where desktop-file-validate rejects it or its Icon= is not the app's, and exports a second desktop entry, a MIME package or metainfo as it is. The app's own desktop entry, applications/<app-id>.desktop, is held to cfg.flatpak.desktopFile's checks whichever placed it: its Icon= and desktop-file-validate are keyed to that place now, not to the field. A source directory that holds what the build writes is refused as well, since it would be copied into itself, growing each time the app is built or exported: files/, and the app's directory, where install and bundle put another copy of files/ and the exported app, compared as written and where links lead, so that the project's own directory is refused where its bin/ is a link elsewhere too. So is one that lies in them, the build's own output, which the next build, install or bundle writes again. The loader leaves an empty source empty, as it does an empty desktop file. FlatpakShareLarge holds the writer to comparing an entry with its copy at constant memory, which the program's data, gigabytes of it in a game, needs on every build: it rewrites a files/ holding a 32 MiB entry, with nothing changed, in a child process whose address space may grow by 16 MiB, with a stand-in llvm-readelf, since the real one, which a write starts for the libraries, would not fit under that limit, and a change in the entry's last byte, in the short block a comparison reads last, is still copied. |
|||
|
52a767fadc |
docs: install, bundle and modules for the Flatpak output
The README's Flatpak section brings in `crafter-build install` and `bundle` after -r, where the sentence on what build-finish writes was, says how they make the app, crafter-build writing the build directory's metadata and the host's flatpak build-finish adding the command and the permissions to it and writing export/, and where that directory is, for trying the app on the host without installing it, says where the repo and remote live and how two installs of one app-id take turns on the remote, where `install` takes the runtime from, what to install where no installation has it and that an app with modules needs the Sdk too, how they ask the host whether it sees the project's bin/ and build/ and refuse a project it does not and who in the sandbox holds the permission they run with, and describes cfg.flatpak.runtime, cfg.flatpak.permissions, which install and bundle print and build-finish judges, and cfg.flatpak.modules; it names install and bundle among the invocations that write AGENTS.md. AGENTS.template.md names what :Flatpak holds now, and says that org.freedesktop.Flatpak is the whole sandbox's while crafter-build's own code uses it only in the host helper, why the trust model allows it, how a test reaches the host without touching the user's installation, and the trap in probing a tool with `command -v` through RunCommandWithTimeout, whose `timeout` cannot run a shell builtin, and lists the locks install keeps on the user's remotes among what goes in ~/.cache/crafter.build/, found by HOME, so that native and Flatpak crafter-builds share them. |
|||
|
71540b24aa |
feat(flatpak): let crafter-build run the host's flatpak
install and bundle run the host's flatpak and flatpak-builder, and the only way out of the sandbox to them is the Flatpak session helper, so the manifest grants --talk-name=org.freedesktop.Flatpak. crafter-build's own code uses it only through HostCommand, for the host's flatpak and flatpak-builder, but the permission is the whole sandbox's: every project.cpp crafter-build loads, its scripts, its dependencies' builds and the programs -r and test start can run host commands through flatpak-spawn --host as well. --filesystem=host already lets all of them arrange that, by writing ~/.bashrc or a systemd user unit; the permission makes it immediate, it does not make it possible. `flatpak update` lists it among the app's new permissions before it asks to proceed. The run flatpak and run install scripts of project.cpp still refuse inside the Flatpak, now for the reason that holds there: they run flatpak themselves, which the sandbox does not have. |