Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
- C host must explicitly be linked against pthread

- need dummy ref to _d_dso_registry to support weak linkage
  • Loading branch information
MartinNowak committed Dec 27, 2014
1 parent afb4cc2 commit 7c8fa30
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/rt/sections_elf_shared.d
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,16 @@ private:
__gshared bool _isRuntimeInitialized;


version (FreeBSD) private __gshared void* dummy_ref;

/****
* Gets called on program startup just before GC is initialized.
*/
void initSections()
{
_isRuntimeInitialized = true;
// reference symbol to support weak linkage
version (FreeBSD) dummy_ref = &_d_dso_registry;
}


Expand Down
8 changes: 4 additions & 4 deletions test/shared/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ $(ROOT)/load_13414: $(ROOT)/%: $(SRC)/%.d $(ROOT)/lib_13414.so $(DRUNTIMESO)
$(QUIET)$(DMD) $(DFLAGS) -of$@ $< $(LINKDL)

$(ROOT)/linkD: $(SRC)/linkD.c $(ROOT)/lib.so $(DRUNTIMESO)
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(ROOT)/lib.so $(LDL)
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(ROOT)/lib.so $(LDL) -pthread

$(ROOT)/linkDR: $(SRC)/linkDR.c $(ROOT)/lib.so $(DRUNTIMESO)
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(DRUNTIMESO) $(LDL)
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(DRUNTIMESO) $(LDL) -pthread

$(ROOT)/loadDR: $(SRC)/loadDR.c $(ROOT)/lib.so $(DRUNTIMESO)
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(LDL)
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(LDL) -pthread

$(ROOT)/host: $(SRC)/host.c $(ROOT)/plugin1.so $(ROOT)/plugin2.so
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(LDL)
$(QUIET)$(CC) $(CFLAGS) -o $@ $< $(LDL) -pthread

$(ROOT)/liblinkdep.so: $(ROOT)/lib.so
$(ROOT)/liblinkdep.so: DFLAGS+=-L$(ROOT)/lib.so
Expand Down
2 changes: 1 addition & 1 deletion test/shared/src/load_13414.d
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import core.runtime, core.atomic, core.sys.linux.dlfcn;
import core.runtime, core.atomic, core.sys.posix.dlfcn;

shared uint tlsDtor, dtor;
void staticDtorHook() { atomicOp!"+="(tlsDtor, 1); }
Expand Down

0 comments on commit 7c8fa30

Please sign in to comment.