[pkg-d-commits] [ldc] 162/211: Implement the betterC switch like DMD does.
Matthias Klumpp
mak at moszumanska.debian.org
Sun Apr 23 22:36:19 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.1.0
in repository ldc.
commit 62a22520282a7f45980a1b959f1958771cdc062d
Author: LemonBoy <thatlemon at gmail.com>
Date: Wed Nov 9 19:01:08 2016 +0100
Implement the betterC switch like DMD does.
Namely, don't emit the ModuleInfo.
---
driver/cl_options.cpp | 5 +++++
driver/ldmd.cpp | 1 +
gen/modules.cpp | 4 ++--
tests/linking/betterc.d | 15 +++++++++++++++
4 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/driver/cl_options.cpp b/driver/cl_options.cpp
index 03aea41..9c80402 100644
--- a/driver/cl_options.cpp
+++ b/driver/cl_options.cpp
@@ -438,6 +438,11 @@ cl::opt<bool, true>
cl::desc("implement http://wiki.dlang.org/DIP25 (experimental)"),
cl::location(global.params.useDIP25));
+cl::opt<bool, true> betterC(
+ "betterC",
+ cl::desc("omit generating some runtime information and helper functions"),
+ cl::location(global.params.betterC));
+
cl::opt<unsigned char, true, CoverageParser> coverageAnalysis(
"cov", cl::desc("Compile-in code coverage analysis\n(use -cov=n for n% "
"minimum required coverage)"),
diff --git a/driver/ldmd.cpp b/driver/ldmd.cpp
index 66e9ed4..6e99c63 100644
--- a/driver/ldmd.cpp
+++ b/driver/ldmd.cpp
@@ -153,6 +153,7 @@ Usage:\n\
files.d D source files\n\
@cmdfile read arguments from cmdfile\n\
-allinst generate code for all template instantiations\n\
+ -betterC omit generating some runtime information and helper functions\n\
-c do not link\n\
-color[=on|off] force colored console output on or off\n\
-conf=path use config file at path\n\
diff --git a/gen/modules.cpp b/gen/modules.cpp
index a4eb36d..c38482e 100644
--- a/gen/modules.cpp
+++ b/gen/modules.cpp
@@ -722,8 +722,8 @@ void codegenModule(IRState *irs, Module *m) {
}
// Skip emission of all the additional module metadata if requested by the
- // user.
- if (!m->noModuleInfo) {
+ // user or the betterC switch is on.
+ if (!global.params.betterC && !m->noModuleInfo) {
// generate ModuleInfo
registerModuleInfo(m);
}
diff --git a/tests/linking/betterc.d b/tests/linking/betterc.d
new file mode 100644
index 0000000..a704718
--- /dev/null
+++ b/tests/linking/betterc.d
@@ -0,0 +1,15 @@
+// RUN: %ldc -betterC -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
+// RUN: %ldc -betterC -defaultlib= -run %s
+
+// CHECK-NOT: ModuleInfoZ
+// CHECK-NOT: ModuleRefZ
+// CHECK-NOT: call void @ldc.register_dso
+version (CRuntime_Microsoft) {
+ extern(C) int mainCRTStartup() {
+ return 0;
+ }
+}
+
+extern (C) int main() {
+ return 0;
+}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list