If we looked at the code that generates the "undefined reference to
`__trunctfdf2'", we find these lines:

 

      if (flags & LONGDBL) {

        _double = (double) GETARG(long double);

      } else {

        _double = GETARG(double);

      }

 

__trunctfdf2 is actually the equivalent of float128_to_float64(). There is
no ARM instruction in the instruction set that generates this operation. And
there is no equivalent of this function in BaseLib we could replace by.

So the compiler introduces an 'intrinsic' to 'workaround'.

As Andrew said, there is the ArmPkg/Library/CompilerIntrinsicsLib for ARM
and AARCH64 that should implement the needed intrinsics. This library is
automatically added to all the UEFI binaries at build time.

 

To solve this issue there are two solutions:

- the good solution: add __trunctfdf2 to CompilerIntrinsicsLib

- less good solution remove '-fno-builtin -nostdlib and -nodefaultlibs' from
the compiler flag to rely on the intrinsics provided by the compiler

 

We actually have some code at ARM we should be able to contribute soon to
fill some missing floating point intrinsics - code we borrowed from NetBSD
project.

 

To summarize, the issue is not a Linaro issue. It is a ARM/AARCH64 EDK2
issue.

 

 

From: Brainerd, Mike [mailto:[email protected]] 
Sent: 06 October 2014 21:12
To: [email protected]
Subject: Re: [edk2] error in AppPkg (StdLib build)

 

Andrew,

Thanks for the reply.

I believe you are confirming that this is a Linaro issue that I need to work
with them?

Regards,

Mike Brainerd

 

From: Andrew Fish [mailto:[email protected]] 
Sent: Monday, October 06, 2014 2:25 PM
To: [email protected]
Subject: Re: [edk2] error in AppPkg (StdLib build)

 

 

On Oct 6, 2014, at 11:45 AM, Brainerd, Mike <[email protected]> wrote:

 

I found a build error that will not let me build AppPkg.

 

 

Mike,

 

/home/mbrainer/DS-5-Workspace/edk2/Build/AppPkg/DEBUG_ARMLINUXGCC/AARCH64/St
dLib/LibC/Stdio/Stdio/OUTPUT/LibStdio.lib(vfprintf.obj): In function
`__vfprintf_unlocked':

/home/mbrainer/DS-5-Workspace/edk2/StdLib/LibC/Stdio/vfwprintf.c:1186:
undefined reference to `__trunctfdf2'

/home/mbrainer/DS-5-Workspace/edk2/StdLib/LibC/Stdio/vfwprintf.c:1186:
undefined reference to `__trunctfdf2'

make: ***
[/home/mbrainer/DS-5-Workspace/edk2/Build/AppPkg/DEBUG_ARMLINUXGCC/AARCH64/A
ppPkg/Applications/Main/Main/DEBUG/Main.dll] Error 1

 

This is the compiler emitting an intrinsic to do a floating point operation,
and the CompilerIntrinsicsLib does not contain this intrinsic so you get a
link failure. If you look at the code this is a cast of a long double to a
double is what is causing the compiler to emit the intrinsic. If you
disassemble vfprintf.obj you would see the assembly language calling the
__truncfdf2 function getting called. 

 

Different compilers, versions of the compilers, and optimization levels can
change what intrinsics get emitted by a compiler. Historically we tried to
avoid writing code that caused intrinsics to be emitted due to the fact that
issues like this can just pop up. But for ARM there was less math support
than for IA32 so we ended up adding the CompilerIntrinsicLib. The need to
avoid intrinsics is the reason the BaseLib has 64-bit math functions, since
they would cause intrinsics to be emitted for IA32. 

 

You could comment/#ifdef out the failing code to make progress. 

 

If some one decides the intrinsics are needed the llvm (clang) project has
implementations of the intrinsics that have a BSD compatible license. 

http://compiler-rt.llvm.org

 

Thanks,

 

Andrew Fish

 

 

Invocation:

 

~/DS-5-Workspace/edk2$ build -v

Build environment: Linux-3.13.0-36-generic-x86_64-with-Ubuntu-14.04-trusty

Build start time: 14:31:56, Oct.03 2014

 

 

Initialize build database started ...

 

Initialize table DataModel started ...

Initialize build database ... DONE!

WORKSPACE        = /home/mbrainer/DS-5-Workspace/edk2

ECP_SOURCE       = /home/mbrainer/DS-5-Workspace/edk2/EdkCompatibilityPkg

EDK_SOURCE       = /home/mbrainer/DS-5-Workspace/edk2/EdkCompatibilityPkg

EFI_SOURCE       = /home/mbrainer/DS-5-Workspace/edk2/EdkCompatibilityPkg

EDK_TOOLS_PATH   = /home/mbrainer/DS-5-Workspace/edk2/BaseTools

 

 

Architecture(s)  = AARCH64

Build target     = DEBUG

Toolchain        = ARMLINUXGCC

 

Active Platform          =
/home/mbrainer/DS-5-Workspace/edk2/AppPkg/AppPkg.dsc

 

FLASH_DEFINITION =

 

Processing meta-data .Found forced library for arch=AARCH64

  ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf [NULL1]

 

Using edk2 svn:16190

 

I captured the output in the attached file "errors_vfwprintf.txt"

It looks to me to be a LINARO binutils error.

Has anyone else seen this? Am I finding a true bug or setup wrong?

Regards,

 

MICHAEL BRAINERD   <image004.png>
Contractor | AMD Server
7171 Southwest Parkway, Austin, TX 78735 USA 
O +(1) 512-602-3491
<image003.png>    <https://www.facebook.com/AMD> facebook  |
<http://www.amd.com/> amd.com

 

----------------------------------------------------------------------------
--
Slashdot TV.  Videos for Nerds.  Stuff that Matters.
 
<http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktr
k_______________________________________________>
http://pubads.g.doubleclick.net/gampad/clk?id=160591471&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
 <mailto:[email protected]> [email protected]
 <https://lists.sourceforge.net/lists/listinfo/edk2-devel>
https://lists.sourceforge.net/lists/listinfo/edk2-devel

 
------------------------------------------------------------------------------
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to