Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Compiler/C++    [ Add a report in this area ]  
Report #:  113472   Status: Closed
compiler output of unnecessary EXPDEF intermitting
Project:  C++Builder Build #:  XE3, XE4
Version:    18.0 Submitted By:   Valence Crearer
Report Type:  Basic functionality failure Date Reported:  3/8/2013 12:41:26 PM
Severity:    Serious / Highly visible problem Last Updated: 4/15/2014 6:18:14 PM
Platform:    All versions Internal Tracking #:   37095
Resolution: Fixed (Resolution Comments) Resolved in Build: : XE6
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: 50
Description
compiler output of unnecessary EXPDEF intermitting

bds2010 "never" produces the EXPDEF's.

It seems that the linker will have problems linking this library with packages only when the EXPDEF's are present.

As we use Packages -- for their drag/drop simplicity -- in statically linked, No RTL DLL .exe's, it is important to us to have no DLL exports -- same as the 2010 bcc32 v 6.21 enterprise/pro did not.

I ran the batch(bp6.cmd) 10 times with bcc32 v 6.51, which compiles 100 times, and this, with --savemem in the batch produced EXPDEF's 81/100 times or 81% of the time.

I ran the batch 10 times withOUT --savemem, the batch produced 0/100 or 0% EXPDEF's.

I ran the batch 10 times with --savemem, but the bcc32 v 6.21, which produced 0/100 or 0% EXPDEF's.

Adding the TXMLDocument reference to the .cpp always produces the EXPDEF, and never links properly.
Steps to Reproduce:
Try this code:
<Unit8.cpp>
//---------------------------------------------------------------------------
#pragma hdrstop

#include <Controls.hpp>

class TCommandProcessor : public TCustomControl {
public:
TNotifyEvent neOnPaint;

__fastcall TCommandProcessor::TCommandProcessor(TComponent* Owner) : TCustomControl(Owner) { }

__published:
__property TNotifyEvent OnPaint = {read=neOnPaint, write=neOnPaint, default=NULL};
};

<\Unit8.cpp>

command script you can use at the command prompt
<bp6.cmd>
@echo off
for %%x in (1 2 3 4 5 6 7 8 9 10) do (
REM del dobj\*/q
"c:\program files\embarcadero\rad studio\10.0\bin\bcc32.exe" -D_DEBUG -n.\dobj -I"c:\program files\embarcadero\rad studio\10.0\include\windows\crtl";"c:\program files\embarcadero\rad studio\10.0\include\windows\sdk";"c:\program files\embarcadero\rad studio\10.0\include\windows\vcl";"c:\program files\embarcadero\rad studio\10.0\include\windows\rtl" -y -Q -P -6 -a4 -c -C -tM -tW -Vn -Vx -Ve -He- -Hs- -C8 -wamb -wamp -wasm -wbbf -wcln -wdef -wnod -w-par -wpin -wsig -wstu -wstv -wucp -wuse -wprc -wstl -wimp -wntn -wpad -wiac -wbcx -wpun -O2 --savemem -v -vi Unit8.cpp
tdump dobj\Unit8.obj | grep -i export
)
echo on
<\bp6.cmd>

command line:
bp6 > out.txt

<bp6_XE4.cmd>
@echo off
for %%x in (1 2 3 4 5 6 7 8 9 10) do (
REM del dobj\*/q
"c:\program files\embarcadero\rad studio\11.0\bin\bcc32.exe" -D_DEBUG -n.\dobj -I"c:\program files\embarcadero\rad studio\11.0\include\windows\crtl";"c:\program files\embarcadero\rad studio\11.0\include\windows\sdk";"c:\program files\embarcadero\rad studio\11.0\include\windows\vcl";"c:\program files\embarcadero\rad studio\11.0\include\windows\rtl" -y -Q -P -6 -a4 -c -C -tM -tW -Vn -Vx -Ve -He- -Hs- -C8 -wamb -wamp -wasm -wbbf -wcln -wdef -wnod -w-par -wpin -wsig -wstu -wstv -wucp -wuse -wprc -wstl -wimp -wntn -wpad -wiac -wbcx -wpun -O2 --savemem -v -vi Unit8.cpp
tdump dobj\Unit8.obj | grep -i export
)
echo on
<\bp6_XE4.cmd>
Workarounds
Compile each member of a library until you get one without the EXPDEF,

then make the library with that object code. It will link fine.

There does not appear to be a workaround for the following code -- that is, this code always produces errant EXPDEF:
<no wordaround>
#include <XMLDoc.hpp>

#if defined(MANAGED_INTERFACE_OPERATORS)
typedef Xml::Xmlintf::_di_IXMLDocument iXMLDocument;
#endif

void RPK() {
  TXMLDocument* XML_ = new TXMLDocument("Test");
  XML_->DOMVendor    = GetDOMVendor("MSXML");
  XML_->LoadFromFile("TestFile");
#if defined(MANAGED_INTERFACE_OPERATORS)
#pragma option push -Jgx
  iXMLDocument XML = *XML_; // ->operator _di_IXMLDocument();
#pragma option pop
#else
  Xmlintf::IXMLDocument* XML = XML_->operator Xmlintf::IXMLDocument *();
#endif

}
<\no workaround>
Attachment
p6_EXPDEF_intermitt.zip
Comments

Tomohiro Takahashi at 3/8/2013 4:28:08 PM -
Could you please attach sample project to reproduce/verify your issue?
Please use Windows Native QC client to attach a .zip to this report. The standalone client comes with C++Builder.

Valence Crearer at 4/1/2013 7:11:08 AM -
I have run into a case that will NOT compile without the EXPDEF.

Xml::Xmlintf::_di_IXMLDocument

in one program will always produce the EXPDEF: Any work around would be appreciated.

Valence Crearer at 3/10/2013 6:06:33 AM -
Done. You'll note that Unit8.cpp is exactly as the example "try this code", and the bp6.cmd is a batch that shows that sometimes bcc32 produces EXPDEF's for the closures, and sometimes it doesn't.

bds2010 "never" produces the EXPDEF's.

It seems that the linker will have problems linking this library with packages only when the EXPDEF's are present.

As we use Packages -- for their drag/drop simplicity -- in statically linked, No RTL DLL .exe's, it is important to us to have no DLL exports -- same as the 2010 bcc32 v 6.21 enterprise/pro did not.

NOTE: Also, the --savemem seems to be pivitol to having bcc32 produce EXPDEF's or not. -- savemem seems to cause intermittent behavior. Without --savemem in the comandline, the compiler seems consistent, but I cannot say whether a source will or will not emit an EXPDEF, only that if it does, it does it more consistently, and if it doesn't, the it doesn't.

I ran the batch(bp6.cmd) 10 times with bcc32 v 6.51, which compiles 100 times, and this, with --savemem in the batch produced EXPDEF's 81/100 times or 81% of the time.

I ran the batch 10 times withOUT --savemem, the batch produced 0/100 or 0% EXPDEF's.

I ran the batch 10 times with --savemem, but the bcc32 v 6.21, which produced 0/100 or 0% EXPDEF's.

<aside>
By the way... v6.21 compiles 10 times in 2.82s @581,089 bytes on my machine and v6.51 compiles 10 times in 12.77s @ 581,133 bytes. (That's a lot more time waiting on a compile, for sure, but I admit 6.51 does a much better job of warnings, though non are in this example.)
<\aside>

Valence Crearer at 6/18/2013 9:03:57 AM -
I still have the issue in Update 1 of XE4...

David suggested that it is fixed... Is this fix something I can test?

Remy Lebeau (TeamB) at 6/18/2013 12:45:16 PM -
Update 1 is not the latest update.  Did you check if the latest Update 1 Hotfix solves the problem?

Valence Crearer at 6/20/2013 7:56:12 AM -
Failed to work in 18.0.4905.60485, presently unable to find newer revision.

Valence Crearer at 9/25/2014 1:03:43 PM -
Confirmed fixed, at least for XE7 -- so far

Server Response from: ETNACODE01