Skip to content

Test that clang flags pointing into an SDK on a different machine are… #1173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lldb/test/API/lang/swift/clangimporter/remap_sdk_path/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS = -Xcc -I$(BUILD_SDK)/usr/include/net

include Makefile.rules

BUILD_SDK := $(BUILDDIR)/LocalSDK/$(shell basename $(SDKROOT))

$(EXE): $(SWIFT_SOURCES)
rm -rf $(BUILDDIR)/LocalSDK
echo "Symlinking iOS SDK into build directory as a fake macOS SDK"
mkdir $(BUILDDIR)/LocalSDK
ln -s $(SDKROOT) $(BUILD_SDK)
echo "Building using SDK in build directory"
$(MAKE) MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
VPATH=$(SRCDIR) -I $(SRCDIR) \
SDKROOT=$(BUILD_SDK) \
SWIFTFLAGS_EXTRAS="$(SWIFTFLAGS_EXTRAS)" \
-f $(SRCDIR)/helper.mk clean main.o a.swiftmodule
echo "Sanity check that our SDK shenanigns worked"
dwarfdump -r 0 $(BUILDDIR)/main.o | grep DW_AT_LLVM_isysroot | grep -q LocalSDK
echo "Linking with regular SDK (otherwise the linker complains)"
$(MAKE) MAKE_DSYM=$(MAKE_DSYM) CC=$(CC) SWIFTC=$(SWIFTC) \
ARCH=$(ARCH) DSYMUTIL=$(DSYMUTIL) \
VPATH=$(SRCDIR) -I $(SRCDIR) \
SDKROOT=$(SDKROOT) \
-f $(SRCDIR)/helper.mk all
echo "Deleting build SDK"
rm -rf $(BUILDDIR)/LocalSDK
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
import os
import unittest2

class TestSwiftRewriteClangPaths(TestBase):

mydir = TestBase.compute_mydir(__file__)

def setUp(self):
TestBase.setUp(self)

@expectedFailureAll(debug_info='dwarf', bugnumber="rdar://problem/62750529")
@skipUnlessDarwin
@skipIfDarwinEmbedded
@swiftTest
def test(self):
"""Test that clang flags pointing into an SDK on a different machine are remapped"""
self.build()
log = self.getBuildArtifact("types.log")
self.runCmd('log enable lldb types -f "%s"' % log)
target, process, thread, bkpt = lldbutil.run_to_name_breakpoint(
self, 'main')
self.expect("p 1", "1")

# Scan through the types log.
logfile = open(log, "r")
found = 0
for line in logfile:
if line.startswith(' SwiftASTContext("a.out")::RemapClangImporterOptions() -- remapped'):
if '/LocalSDK/' in line:
found += 1
self.assertEqual(found, 1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
SWIFT_SOURCES := main.swift
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This space left intentionally blank.