Skip to content

Commit

Permalink
Move -L-w flag to d_do_test and use IN_LLVM in objc.d/h
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Nov 28, 2024
1 parent 7423d0a commit 5d86126
Show file tree
Hide file tree
Showing 14 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion dmd/objc.d
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ extern (C++) struct ObjcClassDeclaration
bool isExtern = false;

/// `true` if this class is a Swift stub
bool isSwiftStub = false;
version(IN_LLVM) bool isSwiftStub = false;

/// Name of this class.
Identifier identifier;
Expand Down
2 changes: 2 additions & 0 deletions dmd/objc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ struct ObjcClassDeclaration
{
d_bool isMeta;
d_bool isExtern;
#if IN_LLVM
d_bool isSwiftStub;
#endif

Identifier* identifier;
ClassDeclaration* classDeclaration;
Expand Down
13 changes: 8 additions & 5 deletions tests/dmd/runnable/extra-files/test16096a.d
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@ module test16096a;
import core.attribute : selector;

extern (Objective-C)
interface Class {
interface Class
{
NSObject alloc() @selector("alloc");
}

extern (Objective-C)
interface NSObject {
NSObject initWithUTF8String(const(char)* str) @selector("initWithUTF8String:");
interface NSObject
{
NSObject initWithUTF8String(in char* str) @selector("initWithUTF8String:");
void release() @selector("release");
}

extern (C) Class objc_lookUpClass(const(char)* name);
extern (C) Class objc_lookUpClass(in char* name);

void test() {
void test()
{
auto c = objc_lookUpClass("NSString");
auto o = c.alloc().initWithUTF8String("hello");
o.release();
Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_call.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES:
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

import core.attribute : selector;

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_call_static.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES:
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

import core.attribute : selector;

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_class.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES: objc_class.m
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

import core.attribute : selector;

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_external_class_19700.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES: objc_instance_variable.m
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

import core.attribute : selector;

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_instance_variable.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES: objc_instance_variable.m
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

import core.attribute : selector;

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_objc_msgSend.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES: objc_objc_msgSend.m
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

import core.attribute : selector;

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_protocol.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES: objc_protocol.m
// REQUIRED_ARGS: -L-lobjc -L-w
// REQUIRED_ARGS: -L-lobjc

import core.attribute : selector;

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_protocol_sections.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES:
// REQUIRED_ARGS: -L-lobjc -L-w
// REQUIRED_ARGS: -L-lobjc

// This file verifies that Objective-C protocols are put in the correct segments
// and sections in the binary. If not, functions from the Objective-C runtime
Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_self_test.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES: objc_self_test.m
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

extern (C) int getValue();

Expand Down
2 changes: 1 addition & 1 deletion tests/dmd/runnable/objc_super_call.d
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// EXTRA_OBJC_SOURCES: objc_super_call.m
// REQUIRED_ARGS: -L-framework -LFoundation -L-w
// REQUIRED_ARGS: -L-framework -LFoundation

import core.attribute : selector;

Expand Down
7 changes: 7 additions & 0 deletions tests/dmd/tools/d_do_test.d
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,13 @@ bool gatherTestParameters(ref TestArgs testArgs, string input_dir, string input_

testArgs.objcSources = split(extraObjcSourcesStr);

// Using the ld64 linker may result in linker warnings being generated
// which are irrelevant to the parts of Objective-C ABI which D implements.
// As such we supress linker warnings for Objective-C tests to avoid
// linker errors when linking against Objective-C compiler output.
if (objc && testArgs.objcSources.length > 0)
testArgs.requiredArgs ~= " -L-w";

// swap / with $SEP
if (envData.sep && envData.sep != "/")
foreach (ref s; testArgs.sources)
Expand Down

0 comments on commit 5d86126

Please sign in to comment.