Skip to content

Commit 7b5b88c

Browse files
Merge pull request #1173 from adrian-prantl/62750529
Test that clang flags pointing into an SDK on a different machine are…
2 parents 7f26c1f + b5cde87 commit 7b5b88c

File tree

4 files changed

+67
-0
lines changed

4 files changed

+67
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS = -Xcc -I$(BUILD_SDK)/usr/include/net
3+
4+
include Makefile.rules
5+
6+
BUILD_SDK := $(BUILDDIR)/LocalSDK/$(shell basename $(SDKROOT))
7+
8+
$(EXE): $(SWIFT_SOURCES)
9+
rm -rf $(BUILDDIR)/LocalSDK
10+
echo "Symlinking iOS SDK into build directory as a fake macOS SDK"
11+
mkdir $(BUILDDIR)/LocalSDK
12+
ln -s $(SDKROOT) $(BUILD_SDK)
13+
echo "Building using SDK in build directory"
14+
$(MAKE) MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
15+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
16+
VPATH=$(SRCDIR) -I $(SRCDIR) \
17+
SDKROOT=$(BUILD_SDK) \
18+
SWIFTFLAGS_EXTRAS="$(SWIFTFLAGS_EXTRAS)" \
19+
-f $(SRCDIR)/helper.mk clean main.o a.swiftmodule
20+
echo "Sanity check that our SDK shenanigns worked"
21+
dwarfdump -r 0 $(BUILDDIR)/main.o | grep DW_AT_LLVM_isysroot | grep -q LocalSDK
22+
echo "Linking with regular SDK (otherwise the linker complains)"
23+
$(MAKE) MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
24+
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
25+
VPATH=$(SRCDIR) -I $(SRCDIR) \
26+
SDKROOT=$(SDKROOT) \
27+
-f $(SRCDIR)/helper.mk all
28+
echo "Deleting build SDK"
29+
rm -rf $(BUILDDIR)/LocalSDK
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import lldb
2+
from lldbsuite.test.lldbtest import *
3+
from lldbsuite.test.decorators import *
4+
import lldbsuite.test.lldbutil as lldbutil
5+
import os
6+
import unittest2
7+
8+
class TestSwiftRewriteClangPaths(TestBase):
9+
10+
mydir = TestBase.compute_mydir(__file__)
11+
12+
def setUp(self):
13+
TestBase.setUp(self)
14+
15+
@expectedFailureAll(debug_info='dwarf', bugnumber="rdar://problem/62750529")
16+
@skipUnlessDarwin
17+
@skipIfDarwinEmbedded
18+
@swiftTest
19+
def test(self):
20+
"""Test that clang flags pointing into an SDK on a different machine are remapped"""
21+
self.build()
22+
log = self.getBuildArtifact("types.log")
23+
self.runCmd('log enable lldb types -f "%s"' % log)
24+
target, process, thread, bkpt = lldbutil.run_to_name_breakpoint(
25+
self, 'main')
26+
self.expect("p 1", "1")
27+
28+
# Scan through the types log.
29+
logfile = open(log, "r")
30+
found = 0
31+
for line in logfile:
32+
if line.startswith(' SwiftASTContext("a.out")::RemapClangImporterOptions() -- remapped'):
33+
if '/LocalSDK/' in line:
34+
found += 1
35+
self.assertEqual(found, 1)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
SWIFT_SOURCES := main.swift
2+
include Makefile.rules
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// This space left intentionally blank.

0 commit comments

Comments
 (0)