Skip to content

Commit f2ad34d

Browse files
committed
FreeBSD: Fix C assert runtime function signature
Fixes dmd-testsuite's runnable/structinit.c, which imports assert.h, causing LDC to validate the signature.
1 parent 31dac3a commit f2ad34d

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

gen/llvmhelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void DtoCAssert(Module *M, Loc loc, LLValue *msg) {
281281
const auto fn = getCAssertFunction(loc, gIR->module);
282282

283283
llvm::SmallVector<LLValue *, 4> args;
284-
if (triple.isOSDarwin()) {
284+
if (triple.isOSDarwin() || triple.isOSFreeBSD()) {
285285
const auto irFunc = gIR->func();
286286
const auto funcName =
287287
irFunc && irFunc->decl ? irFunc->decl->toPrettyChars() : "";

gen/runtime.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,8 @@ llvm::Function *getRuntimeFunction(Loc loc, llvm::Module &target,
341341
// C assert function:
342342
// OSX: void __assert_rtn(const char *func, const char *file, unsigned line,
343343
// const char *msg)
344+
// FreeBSD: void __assert(const char *func, const char *file, int line,
345+
// const char *msg)
344346
// Android: void __assert(const char *file, int line, const char *msg)
345347
// MSVC: void _assert(const char *msg, const char *file, unsigned line)
346348
// Solaris: void __assert_c99(const char *assertion, const char *filename, int line_num,
@@ -376,8 +378,9 @@ static std::vector<PotentiallyLazyType> getCAssertFunctionParamTypes() {
376378
const auto voidPtr = Type::tvoidptr;
377379
const auto uint = Type::tuns32;
378380

379-
if (triple.isOSDarwin() || triple.isOSSolaris() || triple.isMusl() ||
380-
global.params.isUClibcEnvironment || triple.isGNUEnvironment()) {
381+
if (triple.isOSDarwin() || triple.isOSFreeBSD() || triple.isOSSolaris() ||
382+
triple.isMusl() || global.params.isUClibcEnvironment ||
383+
triple.isGNUEnvironment()) {
381384
return {voidPtr, voidPtr, uint, voidPtr};
382385
}
383386
if (triple.getEnvironment() == llvm::Triple::Android) {

0 commit comments

Comments
 (0)