digitalmars.D - New linker error with xml2
- ollie (27/27) Aug 28 2013 I have been seeing a new linker error while building xml2.
- ollie (221/221) Aug 28 2013 If anyone is interested, here is the patch I use to compile xml2:
- Kenji Hara (5/21) Aug 28 2013 Did you rebuild xml2 library after updating/rebuilding dmd code?
I have been seeing a new linker error while building xml2. OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html sxmltest.obj(sxmltest) Error 42: Symbol Undefined _D3alt7zstring22__T9KeyValRecTAyaTAyaZ9KeyValRec 8opEqualsMxFKxS3alt7zstring22__T9KeyValRecTAyaTAyaZ9KeyValRecZb (demangled for your convenience) const(bool function(ref const(alt.zstring.KeyValRec!(immutable(char)[], immutable(char)[]).KeyValRec))) alt.zstring.KeyValRec!(immutable(char)[], immutable(char)[]).KeyValRec.opEquals The error starts with commit: commit 751353c8217596726ab219b7d3a690e8950e409e Author: k-hara <k.hara.pg gmail.com> Date: Sat Aug 24 15:07:18 2013 +0900 To compile xml2, I have made the following changes: change struct Array member toConstArray from safe to trusted because pointers cannot be transformed into arrays in safe code. changed several occurences of 'delete this;' to 'this.destroy();' changed auto doc = new Document(TagData("catalog"); to auto td = TagData("catalog"); auto doc = new Document(td); because of an lvalue problem. (should td be allocated on heap instead?) changed some readln to return to a string instead of passing a string. I am using Win32 with Walter's snn.lib with HeapAlloc calls and obviously git head for dmd etal. Anyone have any ideas why dmd would generate that template function for test\sxml.d after that commit but not before?
Aug 28 2013
If anyone is interested, here is the patch I use to compile xml2: diff --git a/alt/zstring.d b/alt/zstring.d index 356cfda..e021cca 100644 --- a/alt/zstring.d +++ b/alt/zstring.d -674,7 +674,7 struct Array(T) } /// Return unwriteable slice of the buffer. - const(T[]) toConstArray() const safe property nothrow + const(T[]) toConstArray() const trusted property nothrow { if (ptr_ !is null) return ptr_[0..length_]; -1350,7 +1350,8 struct PackedArray(T) /// Element of sortable array of pairs on key struct KeyValRec(K,V) { - alias KeyValRec!(K,V) SameType; +// alias KeyValRec!(K,V) SameType; + alias SameType = KeyValRec!(K,V); K id; V value; -1723,4 +1724,4 unittest put(cd["standalone"]); put(cd["encoding"]); -} \ No newline at end of file +} diff --git a/build.bat b/build.bat index 4be9aaf..052d670 100644 --- a/build.bat +++ b/build.bat -1,7 +1,7 rem Delete all outputs del xmlp.lib sxmltest.exe bookstest.exe conformance.exe 2>NUL -dmd -property -lib -ofxmlp.lib -O -noboundscheck -release -w ^ +dmd -lib -ofxmlp.lib -O -noboundscheck -release -w ^ "alt/zstring.d" "std/xml1.d" "std/xml2.d" ^ "std/xmlp/arraydom.d" "std/xmlp/arraydombuild.d" "std/xmlp/builder.d" ^ "std/xmlp/domparse.d" "std/xmlp/dtdtype.d" ^ -17,15 +17,15 dmd -property -lib -ofxmlp.lib -O -noboundscheck -release -w ^ IF ERRORLEVEL 1 exit /B -dmd -property -ofsxmltest -O -noboundscheck -release "./test/sxml" xmlp.lib +dmd -ofsxmltest -O -noboundscheck -release "./test/sxml" xmlp.lib IF ERRORLEVEL 1 exit /B -dmd -property -ofbookstest -O -noboundscheck -release "./test/books" xmlp.lib +dmd -ofbookstest -O -noboundscheck -release "./test/books" xmlp.lib IF ERRORLEVEL 1 exit /B -dmd -property -ofconformance -O -noboundscheck -release ^ +dmd -ofconformance -O -noboundscheck -release ^ "./test/conformance.d" std/xmlp/jisx0208.d xmlp.lib IF ERRORLEVEL 1 exit /B diff --git a/std/xml1.d b/std/xml1.d index 941c373..3799474 100644 --- a/std/xml1.d +++ b/std/xml1.d -905,7 +905,7 class Tag if (tag_.attr.length > 0) tag_.attr.explode(del); if (del) - delete this; + this.destroy(); } } -1398,7 +1398,7 abstract class Item void explode(bool del) { if (del) - delete this; + this.destroy(); } } -1663,7 +1663,7 public: init(); if (del) - delete this; + this.destroy(); } /** -2130,4 +2130,4 void UnitTest1() unittest { UnitTest1(); -} \ No newline at end of file +} diff --git a/std/xmlp/arraydom.d b/std/xmlp/arraydom.d index 0b7a34c..75e23da 100644 --- a/std/xmlp/arraydom.d +++ b/std/xmlp/arraydom.d -62,7 +62,7 abstract class Item void explode(bool del) { if (del) - delete this; + this.destroy(); } /// This item as text diff --git a/std/xmlp/builder.d b/std/xmlp/builder.d index 98cc176..3274d63 100644 --- a/std/xmlp/builder.d +++ b/std/xmlp/builder.d -69,7 +69,7 abstract class Builder { void explode(bool del) { if (del) - delete this; + this.destroy(); } } diff --git a/std/xmlp/coreprint.d b/std/xmlp/coreprint.d index 1a81011..6cf191a 100644 --- a/std/xmlp/coreprint.d +++ b/std/xmlp/coreprint.d -204,7 +204,7 struct XmlPrinter uintptr_t i = indent; buf[i++] = '<'; buf[i++] = '/'; - buf[i .. i + taglen] = tag; + buf[i .. i + taglen] = tag[]; i += taglen; buf[i] = '>'; } -384,7 +384,7 struct XmlPrinter uintptr_t i = indent; if(i > 0) buf[0..i] = ' '; - buf[i .. $] = s; + buf[i .. $] = s[]; options.putDg(buf); } } diff --git a/std/xmlp/linkdom.d b/std/xmlp/linkdom.d index 582fb9b..678c2a7 100644 --- a/std/xmlp/linkdom.d +++ b/std/xmlp/linkdom.d -1319,7 +1319,7 public: void explode(bool del) { if (del) - delete this; + this.destroy(); } /// Not supported diff --git a/test/Conformance.d b/test/Conformance.d index 68dd9a6..ab7518b 100644 --- a/test/Conformance.d +++ b/test/Conformance.d -755,7 +755,7 int main(string[] args) } } string dinp; - stdin.readln(dinp); + dinp = stdin.readln(); return 0; } diff --git a/test/books.d b/test/books.d index 6c14403..7c6bd71 100644 --- a/test/books.d +++ b/test/books.d -182,7 +182,8 void std_xml1(string s) Book[] books; auto xml = new DocumentParser(s); - auto doc = new Document(TagData("catalog")); + auto td = TagData("catalog"); + auto doc = new Document(td); scope(exit) { diff --git a/test/sxml.d b/test/sxml.d index e3dad14..319698d 100644 --- a/test/sxml.d +++ b/test/sxml.d -17,7 +17,7 import ard = std.xmlp.arraydom; import lnk = std.xmlp.linkdom; import ardb = std.xmlp.arraydombuild; import std.xmlp.builder; -import alt.zstring; +//import alt.zstring; version(GC_STATS) { -255,7 +255,8 void xml1_books(string s) xml.explode(true); // Put it back together again; - auto doc = new Document(TagData("catalog")); + auto td = TagData("catalog"); + auto doc = new Document(td); foreach(book;books) { auto element = new Element("book"); -979,7 +980,7 void testDomAssembly() writeln("Dom construction. <Enter to exit>"); string dinp; - stdin.readln(dinp); + dinp = stdin.readln; }
Aug 28 2013
2013/8/29 ollie <ollie home.net>I have been seeing a new linker error while building xml2. OPTLINK (R) for Win32 Release 8.00.12 Copyright (C) Digital Mars 1989-2010 All rights reserved. http://www.digitalmars.com/ctg/optlink.html sxmltest.obj(sxmltest) Error 42: Symbol Undefined _D3alt7zstring22__T9KeyValRecTAyaTAyaZ9KeyValRec 8opEqualsMxFKxS3alt7zstring22__T9KeyValRecTAyaTAyaZ9KeyValRecZb (demangled for your convenience) const(bool function(ref const(alt.zstring.KeyValRec!(immutable(char)[], immutable(char)[]).KeyValRec))) alt.zstring.KeyValRec!(immutable(char)[], immutable(char)[]).KeyValRec.opEquals The error starts with commit: commit 751353c8217596726ab219b7d3a690e8950e409e Author: k-hara <k.hara.pg gmail.com> Date: Sat Aug 24 15:07:18 2013 +0900Did you rebuild xml2 library after updating/rebuilding dmd code? Because the dmd commit changes the object file places where some instantiated template code are emitted. Kenji Hara
Aug 28 2013
On Thu, 29 Aug 2013 13:11:14 +0900, Kenji Hara wrote:2013/8/29 ollie <ollie home.net>I have been seeing a new linker error while building xml2.Did you rebuild xml2 library after updating/rebuilding dmd code? Because the dmd commit changes the object file places where some instantiated template code are emitted. Kenji HaraThanks for the reply Kenji. Yes, because it is so fast to recompile with dmd, I always recompile both xml2 and GtkD after dmd/druntime/phobos/tools to stay ahead of changes. Using the dmpobj.exe from OpenWatcom, I searched for the missing function in the test program sxmltest.obj and xmlp.lib for compilations just before commit 751353c8217596726ab219b7d3a690e8950e409e and for git-head. The function is only emitted into sxmltest.obj as a EXTDEF record type. EXTDEF(8c) recnum:1545, offset:00010cc8h, len:009ah, chksum:00h(aa) 821 - '_D3std9exception7bailOutFNaNfAyakxAaZv' Type:0 822 - '_D3alt7zstring22__T9KeyValRecTAyaTAyaZ9KeyValRec8opEqualsMxFKxS3alt7zstring22__T9KeyValRecTA aTAyaZ9KeyValRecZb' Type:0 Thanks, ollie
Aug 28 2013
On Thu, 29 Aug 2013 13:11:14 +0900, Kenji Hara wrote:Did you rebuild xml2 library after updating/rebuilding dmd code? Because the dmd commit changes the object file places where some instantiated template code are emitted.After looking into the problem a bit further, I have found that commit 751353c8217596726ab219b7d3a690e8950e409e, specifically the removal of !scx->scopesym->isModule() causes the function decorations to be omitted (pure nothrow safe) from the test program test\sxml.d during compilation, but retaining them during compilation of the library xmlp.lib. By explicitly adding those decorations to the opEquals function of the KeyValRec struct in alt\zstring.d, compilation succeeds with the current git-head. Time permitting, I would be interested in your insight regarding that change. My vague recollection was that those decorations were defaults if not specified. Thanks, Ollie diff from commit 751353c8217596726ab219b7d3a690e8950e409e: diff --git a/src/template.c b/src/template.c index c0e304c..9bb0411 100644 --- a/src/template.c +++ b/src/template.c -5463,8 +5463,7 void TemplateInstance::semantic(Scope *sc, Expressions *fargs) //if (scx && scx->scopesym) printf("3: scx is %s %s\n", scx->scopesym->kind(), scx->scopesym->toChars()); if (scx && scx->scopesym && scx->scopesym->members && - !scx->scopesym->isTemplateMixin() && - !scx->scopesym->isModule() + !scx->scopesym->isTemplateMixin() #if 0 // removed because it bloated compile times /* The problem is if A imports B, and B imports A, and both A * and B instantiate the same template, does the compilation of A function signature in sxmltest.obj after commit 751353c8217596726ab219b7d3a690e8950e409e: const(bool function(ref const(alt.zstring.KeyValRec!(string, string).KeyValRec))) alt.zstring.KeyValRec!(string, string).KeyValRec.opEquals function signature in xmlp.lib before and after commit and sxmltest.obj after explicitly defining decorations on opEquals definition: const(pure nothrow safe bool function(ref const(alt.zstring.KeyValRec!(string, string).KeyValRec))) alt.zstring.KeyValRec!(string, string).KeyValRec.opEquals
Sep 03 2013