Skip to content

Commit c1452f4

Browse files
committed
fix: the .def check read one header and one spelling, and there are two of each
The check's own comment records the defect it was written to prevent: three declarations added for openkal 0.8 without matching .def lines, and the failure appearing one repository away in openkal-llvm-runtime's cross-build. It happened again, with the same signature: ld.lld: error: undefined symbol: __declspec(dllimport) NtQueryVolumeInformationFile The check was right and its SCOPE was wrong, which is the harder kind to notice: it read src/win32.h alone and matched `OKW_IMPORT ... OKW_API' alone, while src/win.h declares the object manager's entries in the plain `__declspec(dllimport) long __stdcall Nt...' form. It reported a number, the number was of the names it knew about, and nothing said the set was partial. It now globs src/*.h and matches both forms: 58 declared across four headers rather than 49 across one. Four names were outside it -- NtFlushBuffersFile, NtQueryVolumeInformationFile, NtReadFile, NtWriteFile -- and all four are now exported. Only one of them was referenced, which is why only one broke a link; the other three were the same latent hazard. Verified locally by cross-building openkal-llvm-runtime's same-source example for x86_64-windows-gnu and aarch64-macos over these working trees.
1 parent 88572c2 commit c1452f4

2 files changed

Lines changed: 31 additions & 5 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,30 @@ jobs:
189189
#
190190
# A check that reads source files must say what they are encoded in, or
191191
# it reports on the runner's locale.
192-
declared = set(re.findall(r'OKW_IMPORT\s+\w+\s+OKW_API\s+(\w+)\s*\(',
193-
open("src/win32.h", encoding="utf-8").read()))
192+
# ⚠️⚠️ EVERY HEADER, AND EVERY SPELLING. THIS CHECK MISSED THE SECOND
193+
# OF EACH AND THE DEFECT IT WAS WRITTEN FOR HAPPENED AGAIN.
194+
#
195+
# It read `src/win32.h' alone and matched `OKW_IMPORT ... OKW_API'
196+
# alone. `src/win.h' declares the object manager's entries in the
197+
# plain form, `__declspec(dllimport) long __stdcall Nt...', so four of
198+
# them were outside what this looked at --- and the failure appeared
199+
# exactly where the comment above says it appeared last time, in
200+
# openkal-llvm-runtime's cross-build, one repository away:
201+
#
202+
# ld.lld: error: undefined symbol:
203+
# __declspec(dllimport) NtQueryVolumeInformationFile
204+
#
205+
# ⭐ THE CHECK WAS RIGHT AND ITS SCOPE WAS WRONG, which is the harder
206+
# kind to notice: it reported a number, the number was of the names it
207+
# knew about, and nothing said the set was partial. So the headers are
208+
# globbed and both forms are matched.
209+
declared = set()
210+
headers = sorted(glob.glob("src/*.h"))
211+
for h in headers:
212+
text = open(h, encoding="utf-8").read()
213+
declared |= set(re.findall(r'OKW_IMPORT\s+\w+\s+OKW_API\s+(\w+)\s*\(', text))
214+
declared |= set(re.findall(
215+
r'__declspec\(dllimport\)[\w\s\*]*?(\w+)\s*\(', text))
194216
exported = set()
195217
for f in glob.glob("port/*.def"):
196218
body = open(f, encoding="utf-8").read().split("EXPORTS", 1)
@@ -203,10 +225,10 @@ jobs:
203225
print(f"::error::declared={len(declared)} exported={len(exported)}; nothing was compared")
204226
sys.exit(1)
205227
missing = sorted(declared - exported)
206-
print(f" {len(declared)} declared, {len(exported)} exported across "
207-
f"{len(glob.glob('port/*.def'))} .def files")
228+
print(f" {len(declared)} declared across {len(headers)} headers, "
229+
f"{len(exported)} exported across {len(glob.glob('port/*.def'))} .def files")
208230
if missing:
209-
print("::error::declared in src/win32.h and exported by no .def:")
231+
print("::error::declared in src/*.h and exported by no .def:")
210232
for m in missing: print(f" {m}")
211233
sys.exit(1)
212234
print(" ok every declared name is exported")

port/ntdll.def

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ LIBRARY ntdll.dll
77
EXPORTS
88
NtClose
99
NtCreateFile
10+
NtFlushBuffersFile
1011
NtQueryDirectoryFile
1112
NtQueryInformationFile
13+
NtQueryVolumeInformationFile
14+
NtReadFile
1215
NtSetInformationFile
16+
NtWriteFile
1317
RtlNtStatusToDosError

0 commit comments

Comments
 (0)