Skip to content
Closed
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
31 changes: 14 additions & 17 deletions src/glue.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,28 +476,25 @@ void genObjFile(Module *m, bool multiobj)
m->sshareddtor = callFuncsAndGates(m, &sshareddtors, NULL, "__modshareddtor");
m->stest = callFuncsAndGates(m, &stests, NULL, "__modtest");

if (m->doppelganger)
if (m->doppelganger && global.params.isWindows)
genModuleInfo(m);
}

if (m->doppelganger)
if (!global.params.betterC)
{
objc_Module_genmoduleinfo_classes();
objmod->termfile();
return;
if (m->doppelganger)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm following the logic correctly, the only difference between the before and after for your patch (assuming betterC flag is not set) is that this call is now omitted. Is that right?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. The change is to always call genModuleInfo. objc_Module_genmoduleinfo_classes is called by genModuleInfo, I removed some of the duplications as well. Seems like the bigger if statement above didn't catch all cases where the module info needed to be generated. m->doppelganger is true if the -lib flag is passed. Before my change the function would return, if the -lib flag was passed, before the module info had been generated.

{
if (!global.params.isWindows)
genModuleInfo(m);
}
else
{
genModuleInfo(m);
genhelpers(m);
}
}

/* Always generate module info, because of templates and -cov.
* But module info needs the runtime library, so disable it for betterC.
*/
if (!global.params.betterC /*|| needModuleInfo()*/)
genModuleInfo(m);

/* Always generate helper functions b/c of later templates instantiations
* with different -release/-debug/-boundscheck/-unittest flags.
*/
if (!global.params.betterC)
genhelpers(m);
else
objc_Module_genmoduleinfo_classes();

objmod->termfile();
}
Expand Down
26 changes: 26 additions & 0 deletions test/runnable/extra-files/test16423lib.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module test16423lib;

enum classFqn = __MODULE__ ~ '.' ~ Class.stringof;

void testFromLibrary()
{
testTypeid();
testFindingClassInfoFromLibrary();
}

private:

class Class {}

void testTypeid()
{
auto c = new Class;
assert(typeid(c) !is null, "typeid not working properly");
}

void testFindingClassInfoFromLibrary()
{
auto classInfo = ClassInfo.find(classFqn);
assert(classInfo !is null, "could not find class info for '" ~ classFqn ~
"' from library");
}
19 changes: 19 additions & 0 deletions test/runnable/extra-files/test16423main.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import test16423lib;

void testFindingClassInfoFromExecutable()
{
auto classInfo = ClassInfo.find(classFqn);
assert(classInfo !is null, "could not find class info for '" ~ classFqn ~
"' from executable");
}

void testFromExecutable()
{
testFindingClassInfoFromExecutable();
}

void main()
{
testFromLibrary();
testFromExecutable();
}
2 changes: 1 addition & 1 deletion test/runnable/test13117.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ int main()
auto size = thisExePath.getSize();
writeln(size);
version (D_LP64)
enum limit = 1_906_432;
enum limit = 2_151_480;
else
enum limit = 1_900_000;
return size > limit * 11 / 10;
Expand Down
2 changes: 1 addition & 1 deletion test/runnable/test13117b.d
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ int main()
version (D_LP64)
enum limit = 2023652;
else
enum limit = 1763328;
enum limit = 1977556;
return size > limit * 11 / 10;
}
2 changes: 1 addition & 1 deletion test/runnable/test16096.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ ${RESULTS_DIR}/runnable/test16096

rm ${dir}/{test16096a.a,test16096}

echo Success >${output_file}
echo Success > "$output_file"
23 changes: 23 additions & 0 deletions test/runnable/test16423.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -e

if [ $OS == "win32" -o $OS == "win64" ]; then
libext=.lib
else
libext=.a
fi

filename_ext=`basename $0`
filename="${filename_ext%.*}"
src=runnable/extra-files
dir=${RESULTS_DIR}/runnable
output_file=${dir}/${filename_ext}.out

$DMD -m${MODEL} -I${src} -of${dir}${SEP}${filename}lib${libext} -lib ${src}/${filename}lib.d
$DMD -m${MODEL} -I${src} -of${dir}${SEP}${filename} ${src}/${filename}main.d ${dir}/${filename}lib${libext}
${RESULTS_DIR}/runnable/${filename}

rm ${dir}/{${filename}lib${libext},${filename}}

echo Success > "$output_file"