Skip to content

Commit ea5d89d

Browse files
committed
tools: Set Swift bug report message in some executable targets
If these programs crash, we want them to print the Swift bug report message, not the default LLVM one, which leads to https://github.com/llvm/llvm-project/issues. While here, hoist the setting of the bug report message to the START_PROGRAM macro so that we don't forget to set it in the future.
1 parent f78a3c7 commit ea5d89d

File tree

7 files changed

+21
-12
lines changed

7 files changed

+21
-12
lines changed

include/swift/Basic/LLVMInitialize.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -19,14 +19,16 @@
1919
#ifndef SWIFT_BASIC_LLVMINITIALIZE_H
2020
#define SWIFT_BASIC_LLVMINITIALIZE_H
2121

22+
#include "swift/Basic/Compiler.h"
2223
#include "llvm/Support/InitLLVM.h"
2324
#include "llvm/Support/ManagedStatic.h"
2425
#include "llvm/Support/PrettyStackTrace.h"
2526
#include "llvm/Support/Signals.h"
2627
#include "llvm/Support/TargetSelect.h"
2728

28-
#define PROGRAM_START(argc, argv) \
29-
llvm::InitLLVM _INITIALIZE_LLVM(argc, argv)
29+
#define PROGRAM_START(argc, argv) \
30+
llvm::InitLLVM _INITIALIZE_LLVM(argc, argv); \
31+
llvm::setBugReportMsg(SWIFT_CRASH_BUG_REPORT_MESSAGE "\n")
3032

3133
#define INITIALIZE_LLVM() \
3234
do { \

lib/DriverTool/sil_opt_main.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -664,7 +664,6 @@ getASTOverrideKind(const SILOptOptions &options) {
664664

665665
int sil_opt_main(ArrayRef<const char *> argv, void *MainAddr) {
666666
INITIALIZE_LLVM();
667-
llvm::setBugReportMsg(SWIFT_CRASH_BUG_REPORT_MESSAGE "\n");
668667
llvm::EnablePrettyStackTraceOnSigInfoForThisThread();
669668

670669
SILOptOptions options;

lib/FrontendTool/FrontendTool.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -2259,7 +2259,6 @@ int swift::performFrontend(ArrayRef<const char *> Args,
22592259
const char *Argv0, void *MainAddr,
22602260
FrontendObserver *observer) {
22612261
INITIALIZE_LLVM();
2262-
llvm::setBugReportMsg(SWIFT_CRASH_BUG_REPORT_MESSAGE "\n");
22632262
llvm::EnablePrettyStackTraceOnSigInfoForThisThread();
22642263

22652264
std::unique_ptr<CompilerInstance> Instance =

tools/swift-def-to-strings-converter/swift-def-to-strings-converter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -14,8 +14,8 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17-
#include "swift/Basic/LLVMInitialize.h"
1817
#include "swift/Basic/Compiler.h"
18+
#include "swift/Basic/LLVMInitialize.h"
1919
#include "swift/Localization/LocalizationFormat.h"
2020
#include "llvm/ADT/ArrayRef.h"
2121
#include "llvm/ADT/SmallString.h"

tools/swift-demangle-yamldump/swift-demangle-yamldump.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -20,6 +20,7 @@
2020
//===----------------------------------------------------------------------===//
2121

2222
#include "swift/Basic/LLVM.h"
23+
#include "swift/Basic/LLVMInitialize.h"
2324
#include "swift/Demangling/Demangle.h"
2425
#include "swift/Demangling/ManglingMacros.h"
2526
#include "llvm/ADT/StringRef.h"
@@ -191,6 +192,8 @@ int main(int argc, char **argv) {
191192
// if main()'s first function call is passing argv[0].
192193
std::rand();
193194
#endif
195+
PROGRAM_START(argc, argv);
196+
194197
llvm::cl::ParseCommandLineOptions(argc, argv);
195198

196199
swift::Demangle::DemangleOptions options;

tools/swift-demangle/swift-demangle.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -14,6 +14,7 @@
1414
//
1515
//===----------------------------------------------------------------------===//
1616

17+
#include "swift/Basic/LLVMInitialize.h"
1718
#include "swift/Demangling/Demangle.h"
1819
#include "swift/Demangling/ManglingFlavor.h"
1920
#include "swift/Demangling/ManglingMacros.h"
@@ -407,6 +408,8 @@ int main(int argc, char **argv) {
407408
// if main()'s first function call is passing argv[0].
408409
std::rand();
409410
#endif
411+
PROGRAM_START(argc, argv);
412+
410413
llvm::cl::ParseCommandLineOptions(argc, argv);
411414

412415
swift::Demangle::DemangleOptions options;

tools/swift-scan-test/swift-scan-test.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// This source file is part of the Swift.org open source project
44
//
5-
// Copyright (c) 2022 Apple Inc. and the Swift project authors
5+
// Copyright (c) 2022 - 2025 Apple Inc. and the Swift project authors
66
// Licensed under Apache License v2.0 with Runtime Library Exception
77
//
88
// See https://swift.org/LICENSE.txt for license information
@@ -17,6 +17,7 @@
1717
#include "swift-c/DependencyScan/DependencyScan.h"
1818
#include "swift/Basic/Defer.h"
1919
#include "swift/Basic/FileTypes.h"
20+
#include "swift/Basic/LLVMInitialize.h"
2021
#include "swift/DependencyScan/DependencyScanJSON.h"
2122
#include "swift/DependencyScan/StringUtils.h"
2223
#include "llvm/ADT/StringExtras.h"
@@ -283,6 +284,8 @@ createArgs(ArrayRef<std::string> Cmd, StringSaver &Saver, Actions Action) {
283284
}
284285

285286
int main(int argc, char *argv[]) {
287+
PROGRAM_START(argc, argv);
288+
286289
llvm::cl::HideUnrelatedOptions(Category);
287290
llvm::cl::ParseCommandLineOptions(argc, argv,
288291
"Test libSwiftScan interfaces\n");

0 commit comments

Comments
 (0)