Skip to content

Commit

Permalink
Do not emit .debug_pubnames on Linux
Browse files Browse the repository at this point in the history
Nothing uses .debug_pubnames or .debug_pubtypes on Linux, so omit
these sections there.

Closes rust-lang#48762
  • Loading branch information
tromey committed Nov 16, 2018
1 parent 9fefb67 commit 47b2154
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,8 +560,23 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateCompileUnit(
unsigned RuntimeVer, const char *SplitName) {
auto *File = unwrapDI<DIFile>(FileRef);

#if LLVM_VERSION_GE(8, 0)
DICompileUnit::DebugNameTableKind kind;
#ifdef __linux__
kind = DICompileUnit::DebugNameTableKind::None;
#else
kind = DICompileUnit::DebugNameTableKind::Default;
#endif
#endif

return wrap(Builder->createCompileUnit(Lang, File, Producer, isOptimized,
Flags, RuntimeVer, SplitName));
Flags, RuntimeVer, SplitName,
DICompileUnit::DebugEmissionKind::FullDebug,
0, true, false
#if LLVM_VERSION_GE(8, 0)
, kind
#endif
));
}

extern "C" LLVMMetadataRef
Expand Down
9 changes: 9 additions & 0 deletions src/test/run-make-fulldeps/no-linux-pubnames/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-include ../tools.mk

# Test that -g doesn't emit .debug_pubnames on Linux.

all:
ifeq ($(UNAME),Linux)
$(RUSTC) -g main.rs
! readelf -WS $(TMPDIR)/main | grep -q debug_pubnames
endif
12 changes: 12 additions & 0 deletions src/test/run-make-fulldeps/no-linux-pubnames/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

pub fn main() {
}

0 comments on commit 47b2154

Please sign in to comment.