Add new CLI options -fno-moduleinfo and -fno-rtti

Using the same names as GDC.
This commit is contained in:
Martin Kinkelin 2023-11-06 21:24:44 +01:00
parent a2bd6a6c95
commit 406df56b82
6 changed files with 15 additions and 5 deletions

View file

@ -575,6 +575,12 @@ cl::opt<bool>
cl::desc("Disable generation of exception stack unwinding "
"code, assuming no Exceptions will be thrown"));
cl::opt<bool> fNoModuleInfo("fno-moduleinfo", cl::ZeroOrMore,
cl::desc("Disable generation of ModuleInfos"));
cl::opt<bool> fNoRTTI("fno-rtti", cl::ZeroOrMore,
cl::desc("Disable generation of TypeInfos"));
cl::opt<bool>
fSplitStack("fsplit-stack", cl::ZeroOrMore,
cl::desc("Use segmented stack (see Clang documentation)"));

View file

@ -101,6 +101,8 @@ void setDefaultMathOptions(llvm::TargetOptions &targetOptions);
extern cl::opt<bool> fNoDiscardValueNames;
extern cl::opt<bool> fNullPointerIsValid;
extern cl::opt<bool> fNoExceptions;
extern cl::opt<bool> fNoModuleInfo;
extern cl::opt<bool> fNoRTTI;
extern cl::opt<bool> fSplitStack;
// Arguments to -d-debug

View file

@ -337,6 +337,8 @@ void parseCommandLine(Strings &sourceFiles) {
global.params.obj = !dontWriteObj;
global.params.useInlineAsm = !noAsm;
global.params.useExceptions = !fNoExceptions;
global.params.useModuleInfo = !fNoModuleInfo;
global.params.useTypeInfo = !fNoRTTI;
// String options
global.params.objname = opts::fromPathString(objectFile);

View file

@ -449,8 +449,8 @@ void codegenModule(IRState *irs, Module *m) {
fatal();
}
// Skip emission of all the additional module metadata if:
// a) the -betterC switch is on,
// Skip emission of the ModuleInfo if:
// a) the -betterC or -fno-moduleinfo switch is on,
// b) requested explicitly by the user via pragma(LDC_no_moduleinfo),
// c) there's no ModuleInfo declaration, or if
// d) the module is a C file.

View file

@ -2162,7 +2162,7 @@ public:
LOG_SCOPE;
// TODO: still required?
if (global.params.betterC) {
if (!global.params.useGC) {
error(
e->loc,
"array concatenation of expression `%s` requires the GC which is not "

View file

@ -64,9 +64,9 @@ public:
/// Return the LLVM type of this Aggregate (w/o the reference for classes)
llvm::StructType *getLLStructType();
/// Whether to suppress the TypeInfo definition for the aggregate via
/// `-betterC`, no `object.TypeInfo`, or `pragma(LDC_no_typeinfo)`.
/// `-betterC` / `-fno-rtti`, no `object.TypeInfo`, or
/// `pragma(LDC_no_typeinfo)`.
bool suppressTypeInfo() const;
//////////////////////////////////////////////////////////////////////////