[fpc-devel] Error: Data element too large / Compilation aborted .. unhandled exception .. AV

2017-03-15 Thread Hans-Peter Suter
Goedenavond,

The following snippet gives the above mentioned error message on Mac
(Yosem.) and aborts the compilation process on Ubuntu (14.04). I'm
using version 3.0.2 [2017/02/12] for i386 and 3.0.2 [2017/02/25] for
x86_64. There are several variants (mentioned in code) which influence the
outcome. Code is from a low-level header file which I likely won't ever
need but I thought it might be of interest nevertheless.

Hans-Peter

PS: in case this should go to Tracker/Mantis? could this do someone, maybe?
(otherwise let me know, thanks).

```pascal (file saved as a.pas)
{$MODE DELPHI}  // (1) _NOT_ using delphi mode works
unit a;

{==}
interface

type
  pSExp = pointer;
  aSExpArr = array[0..((MaxInt div SizeOf(pSExp)) - 1)] of pSExp;
  // aSExpArr = array[0..((MaxInt div 2*SizeOf(pSExp)) - 1)] of pSExp;
  // (2) using a _shorter_ array, eg. ^^ works on Ubuntu (Mac still Error)

  pFoo = ^aFoo;
  aFoo = record
rec: aSExpArr;
  end;

function ahoppla(_x: pFoo): aSExpArr;

{==}
implementation

type
  pData = ^aData;
  aData = record
offset: array[1..24] of byte;  // (3) uncommenting offset works
SExpArr: aSExpArr;
  end;

function ahoppla(_x: pFoo): aSExpArr;
  begin
ahoppla:= pData(_x)^.SExpArr;
// ahoppla:= _x.rec;   // (4) _not_ casting works on Ubuntu
(Mac error)
  end;

end {a}.
```
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread Sven Barth via fpc-devel
Am 15.03.2017 17:06 schrieb "LacaK" :
> But this can be because probably "libippcore.a" is for Linux 64 ...

Yes, the Windows one only supports PE, not ELF.

Regards,
Sven
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread Yury Sidorov

On 3/15/2017 6:06 PM, LacaK wrote:



>>
>>
>> Yes, you can statically link a COFF library created by other compiler.
>>
>> Use objdump as explained earlier to find out the name of ippiThreshold 
function in the static library. It may be prefixed with
"_".
>
> But does it works also on Windows ? (as far as I does not have "objdump" 
utility there?)
> L.

objdump is distributed as part of a FPC or Lazarus release.


Thank you!

Now I can use "objdump -t ippcore.lib" and I get something like this:

ippcore.dll: file format pei-i386

SYMBOL TABLE:
[  0](sec  0)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x .idata$4


ippcore.lib is just an import library for ippcore.dll. You should not 
use it for static linking.
According to the Intel's site you should use the following libs for 
static linking:

ippimt.lib ippsmt.lib ippcorelmt.lib

Yury.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread LacaK



>>
>>
>> Yes, you can statically link a COFF library created by other compiler.
>>
>> Use objdump as explained earlier to find out the name of 
ippiThreshold function in the static library. It may be prefixed with "_".

>
> But does it works also on Windows ? (as far as I does not have 
"objdump" utility there?)

> L.

objdump is distributed as part of a FPC or Lazarus release.


Thank you!

Now I can use "objdump -t ippcore.lib" and I get something like this:

ippcore.dll: file format pei-i386

SYMBOL TABLE:
[  0](sec  0)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x .idata$4
[  1](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x .idata$5
[  2](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x .idata$6
[  3](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 0) 0x .text
[  4](sec  1)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x __imp__ippMalloc@4
[  5](sec  3)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x _ippMalloc@4
[  6](sec  0)(fl 0x00)(ty   0)(scl   2) (nx 0) 0x 
__IMPORT_DESCRIPTOR_ippcore



When I use "objdump -t libippcore.a" I get:
In archive libippcore.a:
objdump: pcorever.o: File format not recognized
objdump: owninit.o: File format not recognized
objdump: ownfinitenans.o: File format not recognized
objdump: owncpufeatures.o: File format not recognized
objdump: owncpudefs.o: File format not recognized
objdump: ippstatus.o: File format not recognized
objdump: ippompinit.o: File format not recognized
objdump: ippnanfp.o: File format not recognized
objdump: ippmalloc64x.o: File format not recognized
objdump: ippmalloc.o: File format not recognized
objdump: ippl2cache.o: File format not recognized
objdump: ippinit.o: File format not recognized
objdump: ippftzdaz.o: File format not recognized
objdump: ippcpufreq.o: File format not recognized
objdump: ippcpufeatures.o: File format not recognized
objdump: ippcpu.o: File format not recognized
objdump: ippcachesize.o: File format not recognized
objdump: ippalignptr.o: File format not recognized
objdump: safeinit32eas.o: File format not recognized
objdump: pscpuinfo32eas.o: File format not recognized
objdump: pscpudef32eas.o: File format not recognized
objdump: ps_destroy_ssx_32e.o: File format not recognized
objdump: intel_f2int.o: File format not recognized

But this can be because probably "libippcore.a" is for Linux 64 ...

L.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread Sven Barth via fpc-devel
Am 15.03.2017 13:56 schrieb "LacaK" :
>
> Dňa 15.3.2017 o 12:54 Yury Sidorov napísal(a):
>
>> On 3/14/2017 4:47 PM, Ladislav Karrach wrote:
>>>
>>>
 Did you try this:
   function ippiThreshold(pSrcDst: PIpp8u; srcDstStep: int;
   roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u;
 thresholdGT: Ipp8u;
   valueGT: Ipp8u): IppStatus; external 'ippi.dll' name
 'ippiThreshold_LTValGTVal_8u_C1IR';
 You should use
 objdump -p ippi.dll
 to get the names of the exported procedures/functions.
>>>
>>> Yes I know, this work: external 'ippi.dll' (I have added also "stdcall")
>>> But my question was regarding how to staticaly link provided libraries
>>> into my EXE (so I do not want distribute also all DLLs)
>>> Just like one can do it in C/C++
>>
>>
>> Yes, you can statically link a COFF library created by other compiler.
>>
>> Use objdump as explained earlier to find out the name of ippiThreshold
function in the static library. It may be prefixed with "_".
>
> But does it works also on Windows ? (as far as I does not have "objdump"
utility there?)
> L.

objdump is distributed as part of a FPC or Lazarus release.

Regards,
Sven
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread LacaK

Dňa 15.3.2017 o 12:54 Yury Sidorov napísal(a):

On 3/14/2017 4:47 PM, Ladislav Karrach wrote:



Did you try this:
  function ippiThreshold(pSrcDst: PIpp8u; srcDstStep: int;
  roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u;
thresholdGT: Ipp8u;
  valueGT: Ipp8u): IppStatus; external 'ippi.dll' name
'ippiThreshold_LTValGTVal_8u_C1IR';
You should use
objdump -p ippi.dll
to get the names of the exported procedures/functions.

Yes I know, this work: external 'ippi.dll' (I have added also "stdcall")
But my question was regarding how to staticaly link provided libraries
into my EXE (so I do not want distribute also all DLLs)
Just like one can do it in C/C++


Yes, you can statically link a COFF library created by other compiler.

Use objdump as explained earlier to find out the name of ippiThreshold 
function in the static library. It may be prefixed with "_".
But does it works also on Windows ? (as far as I does not have "objdump" 
utility there?)

L.

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread Yury Sidorov

On 3/14/2017 4:47 PM, Ladislav Karrach wrote:



Did you try this:
  function ippiThreshold(pSrcDst: PIpp8u; srcDstStep: int;
  roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u;
thresholdGT: Ipp8u;
  valueGT: Ipp8u): IppStatus; external 'ippi.dll' name
'ippiThreshold_LTValGTVal_8u_C1IR';
You should use
objdump -p ippi.dll
to get the names of the exported procedures/functions.

Yes I know, this work: external 'ippi.dll' (I have added also "stdcall")
But my question was regarding how to staticaly link provided libraries
into my EXE (so I do not want distribute also all DLLs)
Just like one can do it in C/C++


Yes, you can statically link a COFF library created by other compiler.

Use objdump as explained earlier to find out the name of ippiThreshold 
function in the static library. It may be prefixed with "_".


Then insert the proper name in the external declaration:

function ippiThreshold(pSrcDst: PIpp8u; srcDstStep: int; roiSize: 
IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u; thresholdGT: Ipp8u; 
valueGT: Ipp8u): IppStatus; external name '';


Also specify proper calling convention: cdecl or stdcall. But it does 
not affect linking if name is explicitly specified.


Yury.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread Ladislav Karrach



Did you try this:
  function ippiThreshold(pSrcDst: PIpp8u; srcDstStep: int;
  roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u; thresholdGT: 
Ipp8u;
  valueGT: Ipp8u): IppStatus; external 'ippi.dll' name 
'ippiThreshold_LTValGTVal_8u_C1IR';
You should use
objdump -p ippi.dll
to get the names of the exported procedures/functions.

Yes I know, this work: external 'ippi.dll' (I have added also "stdcall")
But my question was regarding how to staticaly link provided libraries 
into my EXE (so I do not want distribute also all DLLs)

Just like one can do it in C/C++

-Laco

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread Ladislav Karrach


Note that you can download my ipp FPC interfaces here 
. I do link with statically with 
success on Mac OS X.
Yes I am aware of your port and I have downloaded it, but I am on 
Windows and I cannot succeed in statically linking on Windows ...

L.


___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel


Re: [fpc-devel] Staticaly link C/C++ library (.lib) into FreePascal on Windows

2017-03-15 Thread LacaK



  Error: Undefined symbol:
   IPP__IPPITHRESHOLD_LTVAL_8U_C1IR$PIPP8U$LONGINT$IPPISIZE$BYTE$BYTE$$IPPSTATUS

   test 2: put the library implementation below function
   declaration, eg:

   function _ippiThreshold_LTValGTVal_8u_C1IR(pSrcDst: PIpp8u;
   srcDstStep: int;
   roiSize: IppiSize; thresholdLT: Ipp8u; valueLT: Ipp8u;
   thresholdGT: Ipp8u;
   valueGT: Ipp8u): IppStatus; external;
   {$linklib libippi}

   here I get:
  Error: Undefined symbol:
   IPP__IPPITHRESHOLD_LTVAL_8U_C1IR$PIPP8U$LONGINT$IPPISIZE$BYTE$BYTE$$IPPSTATUS
   (same error if I add: {$linklib ippi} or {$linklib libippi} ...
   ippi.lib and libippi.a are in directory where -Fl points) 



   fix 1: check which convention your library was compiled,

   I think it is stdcall and I have this calling convention there
   (extdecl is macro: {$DEFINE extdecl:=stdcall}  ):
  function _ippiThreshold_LTVal_8u_C1IR(pSrcDst: PIpp8u;srcDstStep:
   int;  roiSize: IppiSize; threshold: Ipp8u; value: Ipp8u): IppStatus;
   extdecl; external;



Awesome. Now we need to check how libippi had exported its
symbols. :-) For example, to check the symbols from the libfoo.a
sent in my previous message:

$ objdump -t libfoo.a
In archive libfoo.a:

libfoo.o: file format pe-i386

SYMBOL TABLE:
[  0](sec -2)(fl 0x00)(ty   0)(scl 103) (nx 1) 0x foo.c
File
*[  2](sec  1)(fl 0x00)(ty  20)(scl   2) (nx 1) 0x _bar*
AUX tagndx 0 ttlsiz 0x0 lnnos 0 next 0
[  4](sec  1)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x .text
AUX scnlen 0xa nreloc 1 nlnno 0
[  6](sec  2)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x .data
AUX scnlen 0x0 nreloc 0 nlnno 0
[  8](sec  3)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x .bss
AUX scnlen 0x0 nreloc 0 nlnno 0
[ 10](sec  4)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x .rdata
AUX scnlen 0x4 nreloc 0 nlnno 0
[ 12](sec  5)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x .rdata$zzz
AUX scnlen 0x2a nreloc 0 nlnno 0
[ 14](sec  6)(fl 0x00)(ty   0)(scl   3) (nx 1) 0x .eh_frame
AUX scnlen 0x38 nreloc 1 nlnno 0

Notice the _bar, now you need to check if libippi exported it as
ippithreshold_ltvalgtval_8u_c1ir, _ippithreshold_ltvalgtval_8u_c1ir or
ipp__ippithreshold_ltval_8u_c1ir. :-)


I forgot a question, could you send your ippi .a files for us? If so, 
I can try a test here. :-)


Yes of course: I have uploaded them here 
http://uschovna.zoznam.sk/download?code=1342688547227-EZyyeVzToDVVkkbJNCbN
But be aware of that I am on Windows, not Linux (Despite this I have 
added to ZIP also .a files as they are installed by Intel into direcotry 
"Linux". In direcory "Windows" are installed only .lib files).
If I can repeat my question: Can I use ".a" libraries also on Windows ? 
If not can I use ".lib" created by C/C++ (I do not know how they are build)

Thank you
-Laco.
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel