Skip to content

Strip out -fno-implicit-modules and friends from ClangImporter options #8527

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
Apr 4, 2024
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
8 changes: 7 additions & 1 deletion lldb/source/Plugins/TypeSystem/Swift/SwiftASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1748,11 +1748,17 @@ void SwiftASTContext::FilterClangImporterOptions(
// Copy back a filtered version of ExtraArgs.
std::vector<std::string> orig_args(std::move(extra_args));
for (auto &arg : orig_args) {
StringRef arg_sr(arg);
// LLDB wants to control implicit/explicit modules build flags.
if (arg_sr == "-fno-implicit-modules" ||
arg_sr == "-fno-implicit-module-maps")
continue;
Comment on lines +1753 to +1755
Copy link

@kastiglione kastiglione Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we put this behind a setting? could it cause issues?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we really need to we can replace with the extra clang flags setting already.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So there should be no need to add another setting to control this.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm worried that by doing this to fix the one bug report, we may create new unforeseen bugs. However, that's entirely speculative on my part. I guess we'll find out whether allowing implicit modules in the presence of explicit modules has any gotchas.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this will do much to fix that specific bug, but I do think that the target's build settings should not control how LLDB imports modules.


// The VFS options turn into fatal errors when the referenced file
// is not found. Since the Xcode build system tends to create a
// lot of VFS overlays by default, stat them and emit a warning if
// the yaml file couldn't be found.
if (StringRef(arg).startswith("-ivfs")) {
if (arg_sr.startswith("-ivfs")) {
// Stash the argument.
ivfs_arg = arg;
continue;
Expand Down
4 changes: 4 additions & 0 deletions lldb/test/API/lang/swift/clangimporter/fmodule_flags/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS = -parse-stdlib -Xcc -DMARKER1 -Xcc -fno-implicit-modules -Xcc -fno-implicit-module-maps -Xcc -DMARKER2

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import lldb
from lldbsuite.test.lldbtest import *
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbutil as lldbutil
import os
import unittest2

class TestSwiftFModuleFlags(TestBase):
@skipIfDarwinEmbedded
@swiftTest
def test(self):
"""Test that -fmodule flags get stripped out"""
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("expression 1", substrs=["1"])

# Scan through the types log.
self.filecheck('platform shell cat "%s"' % log, __file__)
# CHECK: -DMARKER1
# CHECK-NOT: -fno-implicit-modules
# CHECK-NOT: -fno-implicit-module-maps
# CHECK: -DMARKER2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// This space left intentionally blank.