Skip to content

Commit 47b2154

Browse files
committed
Do not emit .debug_pubnames on Linux
Nothing uses .debug_pubnames or .debug_pubtypes on Linux, so omit these sections there. Closes rust-lang#48762
1 parent 9fefb67 commit 47b2154

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

Diff for: src/rustllvm/RustWrapper.cpp

+16-1
Original file line numberDiff line numberDiff line change
@@ -560,8 +560,23 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
560560
unsigned RuntimeVer, const char *SplitName) {
561561
auto *File = unwrapDI<DIFile>(FileRef);
562562

563+
#if LLVM_VERSION_GE(8, 0)
564+
DICompileUnit::DebugNameTableKind kind;
565+
#ifdef __linux__
566+
kind = DICompileUnit::DebugNameTableKind::None;
567+
#else
568+
kind = DICompileUnit::DebugNameTableKind::Default;
569+
#endif
570+
#endif
571+
563572
return wrap(Builder->createCompileUnit(Lang, File, Producer, isOptimized,
564-
Flags, RuntimeVer, SplitName));
573+
Flags, RuntimeVer, SplitName,
574+
DICompileUnit::DebugEmissionKind::FullDebug,
575+
0, true, false
576+
#if LLVM_VERSION_GE(8, 0)
577+
, kind
578+
#endif
579+
));
565580
}
566581

567582
extern "C" LLVMMetadataRef
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-include ../tools.mk
2+
3+
# Test that -g doesn't emit .debug_pubnames on Linux.
4+
5+
all:
6+
ifeq ($(UNAME),Linux)
7+
$(RUSTC) -g main.rs
8+
! readelf -WS $(TMPDIR)/main | grep -q debug_pubnames
9+
endif

Diff for: src/test/run-make-fulldeps/no-linux-pubnames/main.rs

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
pub fn main() {
12+
}

0 commit comments

Comments
 (0)