Skip to content

Commit 47fd4a4

Browse files
authored
0.1.4: retract 0.1.3 — that link error was clause 6.1 working (#4)
0.1.3 给这台机器不提供的两个接口定义了能力字: const kal_uintptr kal_fs_props = 0; const kal_uintptr kal_task_props = 0; 理由是一个只「提问」的程序链接失败。⚠️ 那个失败是机制,不是缺陷。 规范 6.1:「实现不提供的接口,作为链接期定义是缺席的,使用它的 消费者链接失败。」6.2 的表把三个时机分得很清楚: 链接 │ 未定义符号 │ 是否用了该实现不提供的接口 运行 │ 能力字 │ 在**它提供的接口内**它如何表现 给一个没有任何操作的接口定义能力字,是在回答第二个问题, 而第一个问题根本不该被问到。程序于是越过了链接器存在的意义, 接着撞上未定义的 `kal_fs_open` —— 或者更糟,认为自己有一个 零能力的文件系统。SURFACE.txt 从另一侧说同一件事:实现 「导出它所提供的接口的名字,不导出其他任何以 kal_ 开头的名字」。 ⭐ 我当时引了 6.2 的「未赋值的位读作零」来给自己背书,而那条讲的是 **它提供的接口**的字内部的位。结论被复查了,理由没有 —— 去读文件。 本提交的代码面与 0.1.2 逐行一致;多出来的只有把这次判断记下来的注释, 因为下一个人会遇到同样的链接错误,并且会想做同样的事。
1 parent a317db7 commit 47fd4a4

2 files changed

Lines changed: 23 additions & 21 deletions

File tree

mcpp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
[package]
1515
namespace = "mcpplibs"
1616
name = "openkal-opensbi"
17-
version = "0.1.3"
17+
version = "0.1.4"
1818
description = "An implementation of openkal on the RISC-V Supervisor Binary Interface, portable across every machine whose firmware provides one"
1919
license = "Apache-2.0"
2020

src/kal.cpp

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -236,32 +236,34 @@ void* kal_alloc(kal_uintptr size, kal_uintptr align) {
236236
// rather than an omission.
237237
void kal_free(void*, kal_uintptr, kal_uintptr) {}
238238

239-
// ── Capability words for the layers this machine does not have ──────────────
239+
// ── The interfaces this machine does not have are absent, and stay absent ───
240240
//
241-
// ⚠️ A BACKEND MUST DEFINE EVERY PROPERTY WORD, INCLUDING THE ONES THAT READ
242-
// ZERO, OR THE QUESTION ITSELF FAILS TO LINK.
241+
// ⚠️ NO `kal_fs_props`, NO `kal_task_props`, AND THAT IS THE MECHANISM RATHER
242+
// THAN AN OMISSION.
243243
//
244-
// The specification's queries are inline functions over these objects:
245-
//
246-
// inline props properties() { return props{kal_fs_props}; }
247-
//
248-
// so a program that merely ASKS whether a filesystem exists takes the address
249-
// of `kal_fs_props`. Leaving it undefined on a machine that has no filesystem
250-
// makes the question unanswerable in the strongest sense: it does not link.
244+
// 0.1.3 defined both as zero, because a capability-querying program failed to
245+
// link against this backend:
251246
//
252247
// ld.lld: error: undefined symbol: kal_fs_props
253248
// >>> referenced by fs.cppm:136
254249
// >>> obj/main.o:(kal::fs::properties@openkal.fs())
255250
//
256-
// Measured while porting a capability-querying program to this backend. The
257-
// program contained no filesystem call at all — the reference came from the
258-
// query, which is the pattern the whole specification is built on.
251+
// That error is clause 6.1 working. "An interface that an implementation does
252+
// not provide is absent as a link-time definition, and a consumer that uses it
253+
// fails to link." Clause 6.2's table is explicit about which question each
254+
// mechanism answers: the LINKER answers "was an interface used that the
255+
// implementation does not provide", and a capability word answers "how does
256+
// this implementation behave WITHIN AN INTERFACE IT PROVIDES".
259257
//
260-
// Zero is the correct value and is already the specified reading: "an
261-
// unassigned position reads as zero, so that a program compiled against a later
262-
// specification behaves correctly against an earlier implementation". A machine
263-
// with no filesystem and no scheduler is that case taken to its limit.
264-
const kal_uintptr kal_fs_props = 0;
265-
const kal_uintptr kal_task_props = 0;
266-
258+
// Defining the word for an interface with no operations answers the second
259+
// question about something that cannot be asked the first. The program then
260+
// proceeds past the point the linker existed to stop it at, and reaches
261+
// `kal_fs_open` — undefined — or worse, believes it has a filesystem with no
262+
// capabilities. SURFACE.txt says the same thing in the other direction: an
263+
// implementation "exports the names of the interfaces it provides and exports
264+
// no other name beginning with kal_".
265+
//
266+
// 0.1.3 is retracted. A program that asks this backend about a filesystem is a
267+
// program that should not build against this backend, and the graph is where
268+
// that is decided.
267269
} // extern "C"

0 commit comments

Comments
 (0)