Skip to content

Commit ba08290

Browse files
committed
Merge remote-tracking branch 'remotes/origin/main' into whole-wave-funcs
2 parents bc7b9ef + 24438aa commit ba08290

File tree

19 files changed

+275
-418
lines changed

19 files changed

+275
-418
lines changed

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,6 +2252,13 @@ static void AddLibgcc(const ToolChain &TC, const Driver &D,
22522252
if (LGT == LibGccType::SharedLibGcc ||
22532253
(LGT == LibGccType::UnspecifiedLibGcc && D.CCCIsCXX()))
22542254
CmdArgs.push_back("-lgcc");
2255+
// compiler-rt is needed after libgcc for flang on AArch64 for the
2256+
// __trampoline_setup symbol
2257+
if (D.IsFlangMode() && TC.getArch() == llvm::Triple::aarch64) {
2258+
CmdArgs.push_back("--as-needed");
2259+
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "builtins"));
2260+
CmdArgs.push_back("--no-as-needed");
2261+
}
22552262
}
22562263

22572264
void tools::AddRunTimeLibs(const ToolChain &TC, const Driver &D,
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
! Check linker flags for AArch64 linux, since it needs both libgcc and
2+
! compiler-rt, with compiler-rt second when -rtlib=libgcc.
3+
4+
! RUN: %flang -### -rtlib=libgcc --target=aarch64-linux-gnu %S/Inputs/hello.f90 2>&1 | FileCheck %s
5+
6+
! CHECK-LABEL: "{{.*}}ld{{(\.exe)?}}"
7+
! CHECK-SAME: "-lflang_rt.runtime" "-lm"
8+
! CHECK-SAME: "-lgcc" "--as-needed" "-lgcc_s" "--no-as-needed"
9+
! CHECK-SAME: "--as-needed" "{{.*}}{{\\|/}}libclang_rt.builtins.a" "--no-as-needed"

lldb/include/lldb/Symbol/SymbolFile.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,6 @@ class SymbolFile : public PluginInterface {
472472
return false;
473473
};
474474

475-
/// Get number of loaded/parsed DWO files. This is emitted in "statistics
476-
/// dump"
477-
///
478-
/// \returns
479-
/// A pair containing (loaded_dwo_count, total_dwo_count). If this
480-
/// symbol file doesn't support DWO files, both counts will be 0.
481-
virtual std::pair<uint32_t, uint32_t> GetDwoFileCounts() { return {0, 0}; }
482-
483475
virtual lldb::TypeSP
484476
MakeType(lldb::user_id_t uid, ConstString name,
485477
std::optional<uint64_t> byte_size, SymbolContextScope *context,

lldb/include/lldb/Target/Statistics.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,6 @@ struct ModuleStats {
153153
bool symtab_stripped = false;
154154
bool debug_info_had_variable_errors = false;
155155
bool debug_info_had_incomplete_types = false;
156-
uint32_t dwo_file_count = 0;
157-
uint32_t loaded_dwo_file_count = 0;
158156
};
159157

160158
struct ConstStringStats {

lldb/packages/Python/lldbsuite/test/builders/builder.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -247,25 +247,13 @@ def getLLDBObjRoot(self):
247247
def _getDebugInfoArgs(self, debug_info):
248248
if debug_info is None:
249249
return []
250-
251-
debug_options = debug_info if isinstance(debug_info, list) else [debug_info]
252-
option_flags = {
253-
"dwarf": {"MAKE_DSYM": "NO"},
254-
"dwo": {"MAKE_DSYM": "NO", "MAKE_DWO": "YES"},
255-
"gmodules": {"MAKE_DSYM": "NO", "MAKE_GMODULES": "YES"},
256-
"debug_names": {"MAKE_DEBUG_NAMES": "YES"},
257-
"dwp": {"MAKE_DSYM": "NO", "MAKE_DWP": "YES"},
258-
}
259-
260-
# Collect all flags, with later options overriding earlier ones
261-
flags = {}
262-
263-
for option in debug_options:
264-
if not option or option not in option_flags:
265-
return None # Invalid options
266-
flags.update(option_flags[option])
267-
268-
return [f"{key}={value}" for key, value in flags.items()]
250+
if debug_info == "dwarf":
251+
return ["MAKE_DSYM=NO"]
252+
if debug_info == "dwo":
253+
return ["MAKE_DSYM=NO", "MAKE_DWO=YES"]
254+
if debug_info == "gmodules":
255+
return ["MAKE_DSYM=NO", "MAKE_GMODULES=YES"]
256+
return None
269257

270258
def getBuildCommand(
271259
self,

lldb/packages/Python/lldbsuite/test/make/Makefile.rules

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,6 @@ ifeq "$(MAKE_DWO)" "YES"
276276
CFLAGS += -gsplit-dwarf
277277
endif
278278

279-
ifeq "$(MAKE_DEBUG_NAMES)" "YES"
280-
CFLAGS += -gpubnames
281-
endif
282-
283279
ifeq "$(USE_PRIVATE_MODULE_CACHE)" "YES"
284280
THE_CLANG_MODULE_CACHE_DIR := $(BUILDDIR)/private-module-cache
285281
else

lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp

Lines changed: 55 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,115 +3447,80 @@ ProcessGDBRemote::EstablishConnectionIfNeeded(const ProcessInfo &process_info) {
34473447
}
34483448
return error;
34493449
}
3450-
#if !defined(_WIN32)
3451-
#define USE_SOCKETPAIR_FOR_LOCAL_CONNECTION 1
3452-
#endif
3453-
3454-
#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
3455-
static bool SetCloexecFlag(int fd) {
3456-
#if defined(FD_CLOEXEC)
3457-
int flags = ::fcntl(fd, F_GETFD);
3458-
if (flags == -1)
3459-
return false;
3460-
return (::fcntl(fd, F_SETFD, flags | FD_CLOEXEC) == 0);
3461-
#else
3462-
return false;
3463-
#endif
3464-
}
3465-
#endif
34663450

34673451
Status ProcessGDBRemote::LaunchAndConnectToDebugserver(
34683452
const ProcessInfo &process_info) {
34693453
using namespace std::placeholders; // For _1, _2, etc.
34703454

3471-
Status error;
3472-
if (m_debugserver_pid == LLDB_INVALID_PROCESS_ID) {
3473-
// If we locate debugserver, keep that located version around
3474-
static FileSpec g_debugserver_file_spec;
3455+
if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID)
3456+
return Status();
34753457

3476-
ProcessLaunchInfo debugserver_launch_info;
3477-
// Make debugserver run in its own session so signals generated by special
3478-
// terminal key sequences (^C) don't affect debugserver.
3479-
debugserver_launch_info.SetLaunchInSeparateProcessGroup(true);
3458+
ProcessLaunchInfo debugserver_launch_info;
3459+
// Make debugserver run in its own session so signals generated by special
3460+
// terminal key sequences (^C) don't affect debugserver.
3461+
debugserver_launch_info.SetLaunchInSeparateProcessGroup(true);
34803462

3481-
const std::weak_ptr<ProcessGDBRemote> this_wp =
3482-
std::static_pointer_cast<ProcessGDBRemote>(shared_from_this());
3483-
debugserver_launch_info.SetMonitorProcessCallback(
3484-
std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3));
3485-
debugserver_launch_info.SetUserID(process_info.GetUserID());
3463+
const std::weak_ptr<ProcessGDBRemote> this_wp =
3464+
std::static_pointer_cast<ProcessGDBRemote>(shared_from_this());
3465+
debugserver_launch_info.SetMonitorProcessCallback(
3466+
std::bind(MonitorDebugserverProcess, this_wp, _1, _2, _3));
3467+
debugserver_launch_info.SetUserID(process_info.GetUserID());
34863468

34873469
#if defined(__APPLE__)
3488-
// On macOS 11, we need to support x86_64 applications translated to
3489-
// arm64. We check whether a binary is translated and spawn the correct
3490-
// debugserver accordingly.
3491-
int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID,
3492-
static_cast<int>(process_info.GetProcessID()) };
3493-
struct kinfo_proc processInfo;
3494-
size_t bufsize = sizeof(processInfo);
3495-
if (sysctl(mib, (unsigned)(sizeof(mib)/sizeof(int)), &processInfo,
3496-
&bufsize, NULL, 0) == 0 && bufsize > 0) {
3497-
if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
3498-
FileSpec rosetta_debugserver("/Library/Apple/usr/libexec/oah/debugserver");
3499-
debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
3500-
}
3470+
// On macOS 11, we need to support x86_64 applications translated to
3471+
// arm64. We check whether a binary is translated and spawn the correct
3472+
// debugserver accordingly.
3473+
int mib[] = {CTL_KERN, KERN_PROC, KERN_PROC_PID,
3474+
static_cast<int>(process_info.GetProcessID())};
3475+
struct kinfo_proc processInfo;
3476+
size_t bufsize = sizeof(processInfo);
3477+
if (sysctl(mib, (unsigned)(sizeof(mib) / sizeof(int)), &processInfo, &bufsize,
3478+
NULL, 0) == 0 &&
3479+
bufsize > 0) {
3480+
if (processInfo.kp_proc.p_flag & P_TRANSLATED) {
3481+
FileSpec rosetta_debugserver(
3482+
"/Library/Apple/usr/libexec/oah/debugserver");
3483+
debugserver_launch_info.SetExecutableFile(rosetta_debugserver, false);
35013484
}
3485+
}
35023486
#endif
35033487

3504-
shared_fd_t communication_fd = SharedSocket::kInvalidFD;
3505-
#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
3506-
// Use a socketpair on non-Windows systems for security and performance
3507-
// reasons.
3508-
int sockets[2]; /* the pair of socket descriptors */
3509-
if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockets) == -1) {
3510-
error = Status::FromErrno();
3511-
return error;
3512-
}
3488+
llvm::Expected<Socket::Pair> socket_pair = Socket::CreatePair();
3489+
if (!socket_pair)
3490+
return Status::FromError(socket_pair.takeError());
35133491

3514-
int our_socket = sockets[0];
3515-
int gdb_socket = sockets[1];
3516-
auto cleanup_our = llvm::make_scope_exit([&]() { close(our_socket); });
3517-
auto cleanup_gdb = llvm::make_scope_exit([&]() { close(gdb_socket); });
3492+
Status error;
3493+
SharedSocket shared_socket(socket_pair->first.get(), error);
3494+
if (error.Fail())
3495+
return error;
35183496

3519-
// Don't let any child processes inherit our communication socket
3520-
SetCloexecFlag(our_socket);
3521-
communication_fd = gdb_socket;
3522-
#endif
3497+
error = m_gdb_comm.StartDebugserverProcess(
3498+
nullptr, GetTarget().GetPlatform().get(), debugserver_launch_info,
3499+
nullptr, nullptr, shared_socket.GetSendableFD());
35233500

3524-
error = m_gdb_comm.StartDebugserverProcess(
3525-
nullptr, GetTarget().GetPlatform().get(), debugserver_launch_info,
3526-
nullptr, nullptr, communication_fd);
3501+
if (error.Fail()) {
3502+
Log *log = GetLog(GDBRLog::Process);
35273503

3528-
if (error.Success())
3529-
m_debugserver_pid = debugserver_launch_info.GetProcessID();
3530-
else
3531-
m_debugserver_pid = LLDB_INVALID_PROCESS_ID;
3532-
3533-
if (m_debugserver_pid != LLDB_INVALID_PROCESS_ID) {
3534-
#ifdef USE_SOCKETPAIR_FOR_LOCAL_CONNECTION
3535-
// Our process spawned correctly, we can now set our connection to use
3536-
// our end of the socket pair
3537-
cleanup_our.release();
3538-
m_gdb_comm.SetConnection(
3539-
std::make_unique<ConnectionFileDescriptor>(our_socket, true));
3540-
#endif
3541-
StartAsyncThread();
3542-
}
3504+
LLDB_LOGF(log, "failed to start debugserver process: %s",
3505+
error.AsCString());
3506+
return error;
3507+
}
35433508

3544-
if (error.Fail()) {
3545-
Log *log = GetLog(GDBRLog::Process);
3509+
m_debugserver_pid = debugserver_launch_info.GetProcessID();
3510+
shared_socket.CompleteSending(m_debugserver_pid);
35463511

3547-
LLDB_LOGF(log, "failed to start debugserver process: %s",
3548-
error.AsCString());
3549-
return error;
3550-
}
3512+
// Our process spawned correctly, we can now set our connection to use
3513+
// our end of the socket pair
3514+
m_gdb_comm.SetConnection(std::make_unique<ConnectionFileDescriptor>(
3515+
socket_pair->second.release()));
3516+
StartAsyncThread();
35513517

3552-
if (m_gdb_comm.IsConnected()) {
3553-
// Finish the connection process by doing the handshake without
3554-
// connecting (send NULL URL)
3555-
error = ConnectToDebugserver("");
3556-
} else {
3557-
error = Status::FromErrorString("connection failed");
3558-
}
3518+
if (m_gdb_comm.IsConnected()) {
3519+
// Finish the connection process by doing the handshake without
3520+
// connecting (send NULL URL)
3521+
error = ConnectToDebugserver("");
3522+
} else {
3523+
error = Status::FromErrorString("connection failed");
35593524
}
35603525
return error;
35613526
}

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4420,32 +4420,3 @@ void SymbolFileDWARF::GetCompileOptions(
44204420
args.insert({comp_unit, Args(flags)});
44214421
}
44224422
}
4423-
4424-
std::pair<uint32_t, uint32_t> SymbolFileDWARF::GetDwoFileCounts() {
4425-
uint32_t total_dwo_count = 0;
4426-
uint32_t loaded_dwo_count = 0;
4427-
4428-
DWARFDebugInfo &info = DebugInfo();
4429-
const size_t num_cus = info.GetNumUnits();
4430-
for (size_t cu_idx = 0; cu_idx < num_cus; cu_idx++) {
4431-
DWARFUnit *dwarf_cu = info.GetUnitAtIndex(cu_idx);
4432-
if (dwarf_cu == nullptr)
4433-
continue;
4434-
4435-
// Check if this is a DWO unit by checking if it has a DWO ID.
4436-
if (!dwarf_cu->GetDWOId().has_value())
4437-
continue;
4438-
4439-
total_dwo_count++;
4440-
4441-
// If we have a DWO symbol file, that means we were able to successfully
4442-
// load it.
4443-
SymbolFile *dwo_symfile =
4444-
dwarf_cu->GetDwoSymbolFile(/*load_all_debug_info=*/false);
4445-
if (dwo_symfile) {
4446-
loaded_dwo_count++;
4447-
}
4448-
}
4449-
4450-
return {loaded_dwo_count, total_dwo_count};
4451-
}

lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,6 @@ class SymbolFileDWARF : public SymbolFileCommon {
282282
bool GetSeparateDebugInfo(StructuredData::Dictionary &d,
283283
bool errors_only) override;
284284

285-
// Gets a pair of loaded and total dwo file counts.
286-
// For split-dwarf files, this reports the counts for successfully loaded DWO
287-
// CUs and total DWO CUs. For non-split-dwarf files, this reports 0 for both.
288-
std::pair<uint32_t, uint32_t> GetDwoFileCounts() override;
289-
290285
DWARFContext &GetDWARFContext() { return m_context; }
291286

292287
const std::shared_ptr<SymbolFileDWARFDwo> &GetDwpSymbolFile();

lldb/source/Target/Statistics.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ json::Value ModuleStats::ToJSON() const {
7373
debug_info_had_incomplete_types);
7474
module.try_emplace("symbolTableStripped", symtab_stripped);
7575
module.try_emplace("symbolTableSymbolCount", symtab_symbol_count);
76-
module.try_emplace("dwoFileCount", dwo_file_count);
77-
module.try_emplace("loadedDwoFileCount", loaded_dwo_file_count);
7876

7977
if (!symbol_locator_time.map.empty()) {
8078
json::Object obj;
@@ -88,7 +86,7 @@ json::Value ModuleStats::ToJSON() const {
8886

8987
if (!symfile_modules.empty()) {
9088
json::Array symfile_ids;
91-
for (const auto symfile_id : symfile_modules)
89+
for (const auto symfile_id: symfile_modules)
9290
symfile_ids.emplace_back(symfile_id);
9391
module.try_emplace("symbolFileModuleIdentifiers", std::move(symfile_ids));
9492
}
@@ -324,8 +322,6 @@ llvm::json::Value DebuggerStats::ReportStatistics(
324322
uint32_t num_modules_with_incomplete_types = 0;
325323
uint32_t num_stripped_modules = 0;
326324
uint32_t symtab_symbol_count = 0;
327-
uint32_t total_loaded_dwo_file_count = 0;
328-
uint32_t total_dwo_file_count = 0;
329325
for (size_t image_idx = 0; image_idx < num_modules; ++image_idx) {
330326
Module *module = target != nullptr
331327
? target->GetImages().GetModuleAtIndex(image_idx).get()
@@ -357,10 +353,6 @@ llvm::json::Value DebuggerStats::ReportStatistics(
357353
for (const auto &symbol_module : symbol_modules.Modules())
358354
module_stat.symfile_modules.push_back((intptr_t)symbol_module.get());
359355
}
360-
std::tie(module_stat.loaded_dwo_file_count, module_stat.dwo_file_count) =
361-
sym_file->GetDwoFileCounts();
362-
total_dwo_file_count += module_stat.dwo_file_count;
363-
total_loaded_dwo_file_count += module_stat.loaded_dwo_file_count;
364356
module_stat.debug_info_index_loaded_from_cache =
365357
sym_file->GetDebugInfoIndexWasLoadedFromCache();
366358
if (module_stat.debug_info_index_loaded_from_cache)
@@ -435,8 +427,6 @@ llvm::json::Value DebuggerStats::ReportStatistics(
435427
{"totalDebugInfoEnabled", num_debug_info_enabled_modules},
436428
{"totalSymbolTableStripped", num_stripped_modules},
437429
{"totalSymbolTableSymbolCount", symtab_symbol_count},
438-
{"totalLoadedDwoFileCount", total_loaded_dwo_file_count},
439-
{"totalDwoFileCount", total_dwo_file_count},
440430
};
441431

442432
if (include_targets) {

0 commit comments

Comments
 (0)