Skip to content

Commit 78d2061

Browse files
authored
Rollup merge of #118177 - sivadeilra:suppress-llvm-warnings, r=cuviper
Suppress warnings in LLVM wrapper when targeting MSVC The LLVM header files generate many warnings when compiled using MSVC. This makes it difficult to work on the LLVM wrapper code, because the warnings and errors that are relevant to local edits are obscured by the hundreds of lines of warnings from the LLVM Headers.
2 parents f546b44 + 84bc8f0 commit 78d2061

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "SuppressLLVMWarnings.h"
2+
13
#include "llvm-c/BitReader.h"
24
#include "llvm-c/Core.h"
35
#include "llvm-c/Object.h"

compiler/rustc_llvm/llvm-wrapper/Linker.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "SuppressLLVMWarnings.h"
12
#include "llvm/Linker/Linker.h"
23

34
#include "LLVMWrapper.h"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#ifndef _rustc_llvm_SuppressLLVMWarnings_h
2+
#define _rustc_llvm_SuppressLLVMWarnings_h
3+
4+
// LLVM currently generates many warnings when compiled using MSVC. These warnings make it difficult
5+
// to diagnose real problems when working on C++ code, so we suppress them.
6+
7+
#ifdef _MSC_VER
8+
#pragma warning(disable:4530) // C++ exception handler used, but unwind semantics are not enabled.
9+
#pragma warning(disable:4624) // 'xxx': destructor was implicitly defined as deleted
10+
#pragma warning(disable:4244) // conversion from 'xxx' to 'yyy', possible loss of data
11+
#endif
12+
13+
#endif // _rustc_llvm_SuppressLLVMWarnings_h

compiler/rustc_llvm/llvm-wrapper/SymbolWrapper.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// * https://github.com/llvm/llvm-project/blob/8ef3e895ad8ab1724e2b87cabad1dacdc7a397a3/llvm/include/llvm/Object/ArchiveWriter.h
88
// * https://github.com/llvm/llvm-project/blob/8ef3e895ad8ab1724e2b87cabad1dacdc7a397a3/llvm/lib/Object/ArchiveWriter.cpp
99

10+
#include "SuppressLLVMWarnings.h"
1011
#include "llvm/ADT/SmallString.h"
1112
#include "llvm/IR/LLVMContext.h"
1213
#include "llvm/Object/ObjectFile.h"

0 commit comments

Comments
 (0)