Bug 992180 - edk2 does not compile on ARM due to missing arch-dependent header
Summary: edk2 does not compile on ARM due to missing arch-dependent header
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: edk2
Version: 20
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Paolo Bonzini
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: F20FTBFS
TreeView+ depends on / blocked
 
Reported: 2013-08-05 03:28 UTC by Dennis Gilmore
Modified: 2013-12-14 03:47 UTC (History)
6 users (show)

Fixed In Version: edk2-20130515svn14365-7.fc20
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-12-14 03:47:57 UTC


Attachments (Terms of Use)
make build and file names arch dependent (2.46 KB, patch)
2013-08-22 10:53 UTC, Kay Sievers
no flags Details | Diff

Description Dennis Gilmore 2013-08-05 03:28:44 UTC
Your package edk2 failed to build from source in current rawhide.

http://koji.fedoraproject.org/koji/taskinfo?taskID=5711658

Build logs:
root.log: http://kojipkgs.fedoraproject.org/work/tasks/1658/5711658/root.log
build.log: http://kojipkgs.fedoraproject.org/work/tasks/1658/5711658/build.log
state.log: http://kojipkgs.fedoraproject.org/work/tasks/1658/5711658/state.log
NOTE: build logs are cleaned up after 1 week

For details on mass rebuild see https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild

Comment 1 Cole Robinson 2013-08-20 17:14:02 UTC
paolo or laszlo, do you know what's required to cross compile here? I tried

cd edk2-r14365
source ./edksetup.sh
make CC=x86_64-linux-gnu-gcc -C $WORKSPACE/BaseTools

x86_64-linux-gnu-gcc  -c -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -Werror -c -g  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/  BasePeCoff.c -o BasePeCoff.o
In file included from ../Include/X64/ProcessorBind.h:130:0,
                 from ../Include/Common/BaseTypes.h:25,
                 from ../Include/Common/UefiBaseTypes.h:21,
                 from BasePeCoff.c:16:
/usr/lib/gcc/x86_64-linux-gnu/4.7.2/include/stdint.h:3:26: fatal error: stdint.h: No such file or directory

CC=gcc (the default) works fine and continues on:

gcc  -c -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -Werror -c -g  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/  BasePeCoff.c -o BasePeCoff.o
gcc  -c -MD -fshort-wchar -fno-strict-aliasing -fno-merge-constants -nostdlib -Wall -Werror -c -g  -I .. -I ../Include/Common -I ../Include/ -I ../Include/IndustryStandard -I ../Common/ -I .. -I . -I ../Include/X64/  BinderFuncs.c -o BinderFuncs.o

Comment 2 Laszlo Ersek 2013-08-21 07:27:16 UTC
Apologies, the logs in comment 0 are gone, and I don't understand the problem. Can you tell me more about it? What is the reason for cross-compiling?

In any case the gcc command line is identical between the failing and the succeeding case. "BaseTools/Source/C/Include/X64/ProcessorBind.h" seems to include <stdint.h> simply. What does "/usr/lib/gcc/x86_64-linux-gnu/4.7.2/include/stdint.h" contain? Are we sure this isn't a toolchain installation error?

Thanks

Comment 3 Laszlo Ersek 2013-08-21 13:06:45 UTC
I submitted a scratch build for the f20-rebuild target, arch-override armv7hl:

http://koji.fedoraproject.org/koji/taskinfo?taskID=5836570

It failed with:

  make: Entering directory `/builddir/build/BUILD/edk2-r14365/BaseTools'
  make -C Source/C
  Attempting to detect ARCH from 'uname -m': armv7l
  Could not detected ARCH from uname results
  [...]
  GNUmakefile:30: *** ARCH is not defined!.  Stop.

The basetools makefile (BaseTools/Source/C/GNUmakefile) wants to know about the target ARCH it is building for. It has simple detection with uname -m for X64 and IA32, other arches are not recognized.

The TianoCore wiki explains "How to build UEFI for the BeagleBoard":

http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=BeagleBoardPkg#How_to_build_UEFI_for_the_BeagleBoard

In particular, the following toolchains are supported by BaseTools:

http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=ArmPkg/Toolchain

Comment 4 Cole Robinson 2013-08-21 13:13:20 UTC
$ cat /usr/lib/gcc/x86_64-linux-gnu/4.7.2/include/stdint.h#ifndef _GCC_WRAP_STDINT_H
#if __STDC_HOSTED__
# include_next <stdint.h>
#else
# include "stdint-gcc.h"
#endif
#define _GCC_WRAP_STDINT_H
#endif

We cross compile seabios, sgabios, and openbios without issue, so the infrastructure isn't completely broken in all cases.

Logs from the last failure, an issue actually came from i686:

http://koji.fedoraproject.org/koji/taskinfo?taskID=5834440

I'm actually a little confused about paolo's suggestion to cross compile now. If we were building OVMF it makes sense, but right now we are just shipping tools. Are all of these run in the guest context, x86 only? Or are some/all run on the host?

Comment 5 Laszlo Ersek 2013-08-21 13:42:15 UTC
(In reply to Cole Robinson from comment #4)

> We cross compile seabios, sgabios, and openbios without issue, so the
> infrastructure isn't completely broken in all cases.
> 
> Logs from the last failure, an issue actually came from i686:
> 
> http://koji.fedoraproject.org/koji/taskinfo?taskID=5834440

That's actually an understandable error, see <http://koji.fedoraproject.org/koji/getfile?taskID=5834440&name=build.log&offset=-4000>:

    Architecture(s)  = X64
    Build target     = RELEASE
    Toolchain        = GCC46

The koji task says "Arch: i686", but the edk2 build tools were configured for Architecture = X64.

I think this bug is due to Kay's patch for bug 998638 -- it starts

  build -a X64 -b RELEASE -p ShellPkg/ShellPkg.dsc -t GCC46

which is wrong on i686. (See also bug 998638 comment 2.)


> I'm actually a little confused about paolo's suggestion to cross compile
> now. If we were building OVMF it makes sense,

(Not really, as OVMF itself supports nothing but IA32 and X64.)


> but right now we are just
> shipping tools. Are all of these run in the guest context, x86 only? Or are
> some/all run on the host?

This is a mess, of course.

- The build failure in task 5711658 (comment 0) and my repro (task 5836570, comment 3) are genuine. They are not gcc errors or anything like that; the BuildTools bail out on purpose (missing environment variable, and autodetection fails).

- The make command with the CC macro override in comment 1 is not useful. We should actually ignore the errors it reports.


(1) BaseTools is a set of python and C and C++ utilities that must be first built on the host.

(2) These utilities then parse the edk2 DSC/FDF/INF files, and build UEFI code for the target platform, using the (cross) compiler installed on the host.

We don't care about step (2) for now, we just want to build (1). However the "configure" phase of (1) apparently (1a) requires the cross compiler to be present, or at least (1b) needs to be *told* what cross compiler to use in step (2).

(1a) the cross compilers in question are listed in <http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=ArmPkg/Toolchain>.

(1b) Open the other link in comment 3: <http://sourceforge.net/apps/mediawiki/tianocore/index.php?title=BeagleBoardPkg#How_to_build_UEFI_for_the_BeagleBoard>.

It explains:
- install uuid-dev
- get the edk2 tree
- get the toolchain
  (for us, this is either ARMGCC or ARMLINUXGCC, or whatever x86_64-to-arm
  cross compiler Fedora uses),
- [snip]
- run "BeagleBoardPkg/build.sh"

Now "BeagleBoardPkg/build.sh" is important:
(i) it sources "edksetup.sh",
(ii) it configures the TARGET_TOOLS environment variable (which is where ARMGCC or ARMLINUXGCC must be available on the host),
(iii) and *then* runs 'make -C $EDK_TOOLS_PATH', which builds the BaseTools.

This way the BuildTools "configure" phase (1) will know what "inferior" compiler to use.


So, I think we don't want to cross-compile the tools themselves -- instead, we must configure/build them on the host so that they cross-compile UEFI code later on.

I'll ask on edk2-buildtools and CC you (and Jon Masters).

Comment 6 Laszlo Ersek 2013-08-21 13:43:34 UTC
Plus, I'm not sure if BuildTools themselves can actually be built on ARM, as a host platform. If not, then the "armv7hl" koji target arch doesn't make any sense, and must be disabled.

Comment 7 Laszlo Ersek 2013-08-21 14:28:50 UTC
Thread starts here:
http://thread.gmane.org/gmane.comp.bios.tianocore.buildtools.devel/173

Comment 8 Kay Sievers 2013-08-22 10:53:34 UTC
Created attachment 789140 [details]
make build and file names arch dependent

Here is a patch that might make the IA32 build working, I tested it
only locally on x86_64.

It also disabled the ARM build for now, ARM would need more work, if
it should be supported.

Thanks!

Comment 9 Laszlo Ersek 2013-08-22 12:11:29 UTC
I think the patch is good.

(Except perhaps the change to %description isn't complete -- we should probably mention that the package only contains build tools and the UEFI shell.)

Comment 10 Kay Sievers 2013-08-22 13:34:30 UTC
Oh, it's only the description for the sources, no normal user will ever
see that, as only the sub-packages contain files and will be installed,
right?

Comment 11 Laszlo Ersek 2013-08-22 13:41:47 UTC
Fine by me, if Cole doesn't mind it :)

Comment 12 Dennis Gilmore 2013-08-22 16:47:23 UTC
It would be nice for us to build arm and x86 versions of edk2

Comment 13 Laszlo Ersek 2013-08-22 17:52:03 UTC
Hi Dennis,

I'm trying to figure out how to build just the Build Tools for ARM, not even UEFI code. See comment 7 -- no answers yet.

Comment 14 Paolo Bonzini 2013-08-27 12:33:35 UTC
What we want is:

- build tools for ARM

- UEFI code for x86_64

I don't recall why building the build tools for ARM requires a cross-compiler, and the logs are gone.  Perhaps I got confused by the ARCH autodetection that Laszlo mentioned and the bug has to be split.

This is firmware meant to run with qemu-system-x86_64, and we do not need to support it on 32-bit machines.  We need to build the same firmware on all machines including ARM (hence the cross-compilation reference in the subject).  Building UEFI code for 32-bit on 32-bit machines, and on 64-bit for 64-bit machines, makes no sense for the OVMF image, even though it may make some sense for the UEFI shell.

Comment 15 Laszlo Ersek 2013-08-27 12:48:38 UTC
(In reply to Paolo Bonzini from comment #14)
> What we want is:
> 
> - build tools for ARM
> 
> - UEFI code for x86_64
> 
> I don't recall why building the build tools for ARM requires a
> cross-compiler, and the logs are gone.

See comment 3 for my repro. I quoted the relevant parts of the error.

I don't even know for sure *if* building the build tools for ARM requires a cross compiler. This requirement is *implied* (but not spelled out anywhere) in the TianoCore wiki, and relied on by the "BeagleBoardPkg/build.sh" build script.

See (1b)/(ii) and (1b)/(iii) in comment 5. In a nutshell, the build tools themselves are only built after TARGET_TOOLS is configured (by finding the cross compiler).

Now the cross compiler might not be a hard dependency -- something incidental through or around the TARGET_TOOLS configuration might enable the BuildTools to build. But I don't know for sure what, and I figured people on edk2-buildtools-devel would know.

> Perhaps I got confused by the ARCH
> autodetection that Laszlo mentioned and the bug has to be split.
> 
> This is firmware meant to run with qemu-system-x86_64, and we do not need to
> support it on 32-bit machines.  We need to build the same firmware on all
> machines including ARM (hence the cross-compilation reference in the
> subject).

So, basically you want to build x86_64 UEFI code on an ARM host, right?

IOW my thinking has been reverse -- we need ARM-to-x86_64 cross compilation, correct?

Comment 16 Cole Robinson 2013-08-27 20:10:53 UTC
I pushed Kay's second patch to rawhide/f20, building packages now. We can keep this open to track dropping the ExclusiveArch bit, and adding cross compilation.

Comment 17 Paolo Bonzini 2013-08-29 13:39:38 UTC
No, Kay's patch is wrong.  Please revert it except for the ExclusiveArch bit.

The EFI shell should be in a noarch subpackage.  If Kay wants both 32-bit and 64-bit shell binaries, he should build the ShellPkg twice.  So in fact I suggest reverting both of Kay's patches.

Comment 18 Dennis Gilmore 2013-09-11 04:21:55 UTC
(In reply to Paolo Bonzini from comment #14)
> What we want is:
> 
> - build tools for ARM
> 
> - UEFI code for x86_64
> 
> I don't recall why building the build tools for ARM requires a
> cross-compiler, and the logs are gone.  Perhaps I got confused by the ARCH
> autodetection that Laszlo mentioned and the bug has to be split.

It doesn't but as with many upstream projects they write their documentation assuming you cross compile arm code from a x86 machine
 
> This is firmware meant to run with qemu-system-x86_64, and we do not need to
> support it on 32-bit machines.  We need to build the same firmware on all
> machines including ARM (hence the cross-compilation reference in the
> subject).  Building UEFI code for 32-bit on 32-bit machines, and on 64-bit
> for 64-bit machines, makes no sense for the OVMF image, even though it may
> make some sense for the UEFI shell.

in this case it should be "ExclusiveArch: x86_64" with a bug filed blocking each of the arch trackers explaining the situation. id like us to offer an option of a arm build for use with qemu-system-arm but im not stuck on it.  Note Fedora only supports UEFI on x86_64 if you wanted a 32 bit version to support other OS's it wouldn't hurt. but would not be useful in testing Fedora

Comment 19 Fedora End Of Life 2013-09-16 15:18:07 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 20 development cycle.
Changing version to '20'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/BugZappers/HouseKeeping/Fedora20

Comment 20 Paolo Bonzini 2013-09-20 14:07:47 UTC
> in this case it should be "ExclusiveArch: x86_64" with a bug filed blocking 
> each of the arch trackers explaining the situation

No, this wouldn't work.

The package is 64-bit x86 code that runs on ARM, PowerPC, s390, even 32-bit x86 through emulation.

If we make it "ExclusiveArch: x86_64", the Koji instances for PPC and s390 will not be able to build it, and this will break the PPC and s390 qemu packages.

Comment 21 Fedora Update System 2013-11-08 13:52:01 UTC
edk2-20130515svn14365-7.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/edk2-20130515svn14365-7.fc20

Comment 22 Fedora Update System 2013-11-08 18:40:37 UTC
Package edk2-20130515svn14365-7.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing edk2-20130515svn14365-7.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2013-20957/edk2-20130515svn14365-7.fc20
then log in and leave karma (feedback).

Comment 23 Fedora Update System 2013-12-14 03:47:57 UTC
edk2-20130515svn14365-7.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.