From ae9581c1e4b96de6707c71eb45dcc9c10dd4d402 Mon Sep 17 00:00:00 2001 From: Vladimir Panteleev Date: Sun, 25 Nov 2018 13:14:39 +0000 Subject: [PATCH] Fix Issue 19433 - Don't consume --DRT-* options if rt_cmdline_enabled is false --- posix.mak | 2 +- src/rt/dmain2.d | 4 +++- test/config/Makefile | 17 +++++++++++++++++ test/config/src/test19433.d | 7 +++++++ 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 test/config/Makefile create mode 100644 test/config/src/test19433.d diff --git a/posix.mak b/posix.mak index 533940e9fb..6c0a8255ff 100644 --- a/posix.mak +++ b/posix.mak @@ -253,7 +253,7 @@ HAS_ADDITIONAL_TESTS:=$(shell test -d test && echo 1) ifeq ($(HAS_ADDITIONAL_TESTS),1) ADDITIONAL_TESTS:=test/init_fini test/exceptions test/coverage test/profile test/cycles test/allocations test/typeinfo \ test/aa test/hash \ - test/thread test/unittest test/imports test/betterc test/stdcpp + test/thread test/unittest test/imports test/betterc test/stdcpp test/config ADDITIONAL_TESTS+=$(if $(SHARED),test/shared,) endif diff --git a/src/rt/dmain2.d b/src/rt/dmain2.d index 1261ecba96..c195309296 100644 --- a/src/rt/dmain2.d +++ b/src/rt/dmain2.d @@ -443,7 +443,9 @@ extern (C) int _d_run_main(int argc, char **argv, MainFunc mainFunc) size_t j = 0; foreach (arg; args) { - if (arg.length < 6 || arg[0..6] != "--DRT-") // skip D runtime options + import rt.config : rt_cmdline_enabled; + + if (!rt_cmdline_enabled!() || arg.length < 6 || arg[0..6] != "--DRT-") // skip D runtime options { argsCopy[j++] = (argBuff[0 .. arg.length] = arg[]); argBuff += arg.length; diff --git a/test/config/Makefile b/test/config/Makefile new file mode 100644 index 0000000000..b3c8f3d454 --- /dev/null +++ b/test/config/Makefile @@ -0,0 +1,17 @@ +include ../common.mak + +TESTS:=test19433 + +.PHONY: all clean +all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) + +$(ROOT)/%: $(SRC)/%.d + $(QUIET)$(DMD) $(DFLAGS) -of$@ $< + +$(ROOT)/test19433.done: $(ROOT)/test19433 + @echo Testing test19433 + $(QUIET)$(ROOT)/test19433 --DRT-dont-eat-me + @touch $@ + +clean: + rm -rf $(ROOT) diff --git a/test/config/src/test19433.d b/test/config/src/test19433.d new file mode 100644 index 0000000000..1c58145103 --- /dev/null +++ b/test/config/src/test19433.d @@ -0,0 +1,7 @@ +extern(C) __gshared bool rt_cmdline_enabled = false; + +void main(string[] args) +{ + assert(args.length == 2); + assert(args[1] == "--DRT-dont-eat-me"); +}