openkal-linux 0.5.0: implement on the kernel, so that a C library can sit above - #1
Merged
Conversation
… sit above Version 0.4 was written upon the C library of the host. That is a correct implementation of openkal and it fails for the program openkal exists to support. A C library ported onto openkal defines write, malloc and open; so does the host's; one program cannot reach both definitions, so this implementation's calls resolved to the ported library, which called openkal, which called this implementation again. Neither side reads as though anything is wrong. Every interface is now implemented on the kernel's own system-call interface for x86_64 and aarch64, and the objects reference no C library symbol - which CI asserts against the objects rather than the source, and which a probe confirms the check can detect the absence of. The kernel's structure layouts are declared here rather than taken from a header, because the same-named structure differs between C libraries and an implementation compiled against one and linked with another would read the wrong fields. A "freestanding" feature supplies what a C library's first object ordinarily supplies, for a program that is a C library: the program entry, a thread-local storage block per execution context built from the program's own PT_TLS segment, and execution contexts created with clone. Without it, contexts come from the C library the program is linked against, which is the ordinary configuration and remains the default. kal_fs_preopen(0) now reports the working directory's absolute path rather than ".", because a C library above openkal must report a working directory and could not have done so. The four operations and one property openkal 0.5 adds are implemented, and a sixth conformance suite observes each of them by its effect.
The feature is renamed from 'freestanding' to 'standalone' and restated: what it selects is whether this implementation is the whole of the program's environment, which is a property of the program. The finding that produced it is unchanged and is now stated generally --- an implementation must not depend upon a runtime the program may itself supply --- with a C library as the instance rather than as the subject.
…s own name The workflow named a feature this package renamed --- `freestanding' became `standalone', because the arrangement is a statement about the program and not about how much of a C library is present --- so the two steps that assert this version's central property were building the default configuration and asserting nothing about the one they name. It also ran only this package's own tests. The specification now carries the behavioural half of clause 9 as a suite every implementation runs, so that is run first and this package's own tests, which examine the operations version 0.5 added, follow it. Both are now run under two compiler families. An implementation is a contract's evidence, and a contract that holds only under the compiler its author used is a description of that compiler.
…ths openkal names
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The finding this release exists for
Version 0.4 was written upon the C library of the host. That is a correct
implementation of openkal for a program that carries no runtime of its own, and
it is wrong for the program clause 1 of the specification names first among the
consumers it expects.
A C library ported onto openkal defines
write,mallocandopen. So doesthe host's. Two definitions of one name cannot both be reached from one program,
so an implementation that calls the host's calls the ported one instead — and
the ported one calls openkal, which calls the implementation, which calls it
again. The recursion is unbounded and it is not visible in either side's
source.
The remedy is not a linking arrangement. An implementation that may sit beneath
a program supplying its own runtime must not depend upon one. Every source is
rewritten on the kernel's own system-call interface, and CI asserts the property
against the objects rather than against the source, because a source can reach a
C library through a macro.
A second consequence is less obvious and equally binding. A structure passed to
the kernel has the kernel's layout, which is not the layout of the same-named
structure in any particular C library: musl's
struct statand glibc's differ,and an implementation compiled against one and linked with the other reads the
wrong fields. The kernel's own layouts are declared in
src/sys.h.What is new
src/sys.h— the calling convention for x86_64 and aarch64, the numbers, thekernel's structure layouts, and the error table.
src/tls.h,src/start.cpp— under thestandalonefeature: the programentry, a thread-local block per execution context built from the program's own
PT_TLS, and execution contexts created withclonedirectly.kal_fs_openwith its six flags,kal_fs_truncate,kal_fs_file_info,kal_stream_props, the five error values, andKAL_TASK_PROP_THREAD_LOCAL.tests/conformance_additions.cpp— twenty assertions on those additions.freestandingis nowstandaloneThe feature is a statement about the program, not about how much of a C library
is present. openkal says nothing about what else a program contains: ordinarily
a program carries a runtime that has already received control and already
creates execution contexts, and this implementation borrows both. Sometimes
there is none, and then this implementation supplies both. The consumer that
knows which arrangement holds is the one that declares it.
Continuous integration
Two compiler families, gcc and llvm. Each row runs the specification's own
conformance suite (91 observations, all held), this package's tests, the
surface comparison in both forms, the assertion that the objects reference no C
library symbol, and a probe that the last assertion fails when it should.
Requires
mcpplibs/openkal#1.