diff --git a/posix.mak b/posix.mak index b371bdaeed..6678715d9e 100644 --- a/posix.mak +++ b/posix.mak @@ -231,7 +231,7 @@ UT_MODULES:=$(patsubst src/%.d,$(ROOT)/unittest/%,$(SRCS)) 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/thread test/unittest + test/thread test/unittest test/imports ADDITIONAL_TESTS+=$(if $(SHARED),test/shared,) endif @@ -241,7 +241,7 @@ unittest : $(UT_MODULES) $(addsuffix /.run,$(ADDITIONAL_TESTS)) @echo done else unittest : unittest-debug unittest-release -unittest-%: +unittest-%: target $(MAKE) -f $(MAKEFILE) unittest OS=$(OS) MODEL=$(MODEL) DMD=$(DMD) BUILD=$* endif diff --git a/src/core/runtime.d b/src/core/runtime.d index ab995882e1..b9b3573293 100644 --- a/src/core/runtime.d +++ b/src/core/runtime.d @@ -650,13 +650,18 @@ extern (C) UnitTestResult runModuleUnitTests() } } } - import rt.config : rt_configOption; + + import core.internal.traits : externDFunc; + alias rt_configCallBack = string delegate(string) @nogc nothrow; + alias fn_configOption = string function(string opt, scope rt_configCallBack dg, bool reverse) @nogc nothrow; + alias rt_configOption = externDFunc!("rt.config.rt_configOption", fn_configOption); + if (results.passed != results.executed) { // by default, we always print a summary if there are failures. results.summarize = true; } - else switch (rt_configOption("testmode")) + else switch (rt_configOption("testmode", null, false)) { case "": // By default, run main. Switch to only doing unit tests in 2.080 @@ -674,7 +679,7 @@ extern (C) UnitTestResult runModuleUnitTests() results.summarize = !results.runMain; break; default: - throw new Error("Unknown --DRT-testmode option: " ~ rt_configOption("testmode")); + throw new Error("Unknown --DRT-testmode option: " ~ rt_configOption("testmode", null, false)); } return results; diff --git a/src/core/thread.d b/src/core/thread.d index f69defca35..6379e6c6bd 100644 --- a/src/core/thread.d +++ b/src/core/thread.d @@ -304,7 +304,6 @@ else version( Posix ) { version (Shared) { - import rt.sections; Thread obj = cast(Thread)(cast(void**)arg)[0]; auto loadedLibraries = (cast(void**)arg)[1]; .free(arg); @@ -317,7 +316,11 @@ else version( Posix ) // loadedLibraries need to be inherited from parent thread // before initilizing GC for TLS (rt_tlsgc_init) - version (Shared) inheritLoadedLibraries(loadedLibraries); + version (Shared) + { + externDFunc!("rt.sections_elf_shared.inheritLoadedLibraries", + void function(void*) @nogc nothrow)(loadedLibraries); + } assert( obj.m_curr is &obj.m_main ); obj.m_main.bstack = getStackBottom(); @@ -404,7 +407,11 @@ else version( Posix ) append( t ); } rt_moduleTlsDtor(); - version (Shared) cleanupLoadedLibraries(); + version (Shared) + { + externDFunc!("rt.sections_elf_shared.cleanupLoadedLibraries", + void function() @nogc nothrow)(); + } } catch( Throwable t ) { @@ -712,15 +719,17 @@ class Thread version (Shared) { - import rt.sections; - auto libs = pinLoadedLibraries(); + auto libs = externDFunc!("rt.sections_elf_shared.pinLoadedLibraries", + void* function() @nogc nothrow)(); + auto ps = cast(void**).malloc(2 * size_t.sizeof); if (ps is null) onOutOfMemoryError(); ps[0] = cast(void*)this; ps[1] = cast(void*)libs; if( pthread_create( &m_addr, &attr, &thread_entryPoint, ps ) != 0 ) { - unpinLoadedLibraries(libs); + externDFunc!("rt.sections_elf_shared.unpinLoadedLibraries", + void function(void*) @nogc nothrow)(libs); .free(ps); onThreadError( "Error creating thread" ); } diff --git a/test/imports/Makefile b/test/imports/Makefile new file mode 100644 index 0000000000..e4f6766888 --- /dev/null +++ b/test/imports/Makefile @@ -0,0 +1,14 @@ +include ../common.mak + +TESTS:=bug18193 + +.PHONY: all clean +all: $(addprefix $(ROOT)/,$(addsuffix .done,$(TESTS))) + +$(ROOT)/%.done: + @echo Testing $* + @mkdir -p $(basename $@) + $(QUIET)$(DMD) -version=Shared -o- -deps=$@ -Isrc -I../../import src/$* + +clean: + rm -rf $(GENERATED) diff --git a/test/imports/src/bug18193.d b/test/imports/src/bug18193.d new file mode 100644 index 0000000000..bd3fd521d0 --- /dev/null +++ b/test/imports/src/bug18193.d @@ -0,0 +1,2 @@ +import core.runtime; +import core.thread;