Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions posix.mak
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
11 changes: 8 additions & 3 deletions src/core/runtime.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down
21 changes: 15 additions & 6 deletions src/core/thread.d
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down Expand Up @@ -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 )
{
Expand Down Expand Up @@ -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" );
}
Expand Down
14 changes: 14 additions & 0 deletions test/imports/Makefile
Original file line number Diff line number Diff line change
@@ -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)
2 changes: 2 additions & 0 deletions test/imports/src/bug18193.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
import core.runtime;
import core.thread;