Re: [edk2] [edk2-buildtools] Building on Mac OS X 10.6.8 problems

Subject: Re: [edk2] [edk2-buildtools] Building on Mac OS X 10.6.8 problems

From: egon@ragequ.it

To: edk2-devel@lists.sourceforge.net

Date: 2011-07-02 21:03:14

It works!

I took cue from your comment about the linker and actually tried using the Xcode3 ld (I relocated the Xcode3 tools to /Xcode3 before I updated to 4 in case this sort of thing happened) to link the problematic files, which worked without throwing that error. I then updated the tools_def.txt to use this version of ld:

*_XCLANG_*_DLINK_PATH   = /Xcode3/usr/bin/ld
*_XCLANG_*_DLINK_PATH   = /Xcode3/usr/bin/ld

Part way through the build it errored out telling me to run:
make -C /Users/x/Projects/EFI/edk2_take5/BaseTools/Source/C

I did so and the next time it built successfully, and the emulator runs and actually boots into the shell.

Thanks very much for your help.

On 02/07/2011, at 12:45 PM, egon@ragequ.it wrote:

Yeah the IntelFrameworkModulePkg bug has been fixed in the version of the source, sorry I should have checked that.

I'm using Xcode 4, the ld being used is the llvm/clang one:

$ ld -v
@(#)PROGRAM:ld  PROJECT:ld64-123.2
llvm version 2.9svn, from Apple Clang 2.0 (build 137)

I'll see if I can figure out what's going on with the linker, this is a bit out of my depth though :)

Cheers.

On 02/07/2011, at 12:40 PM, Andrew Fish wrote:

Are you using Xcode 3.2.6? I seem to recall a linker bug in an older version?

I think the IntelFrameworkModulePkg patch was as simple as:

if ((a == b)) {
should be:
if (a==b) {

clang thinks the double parenthesis on the if means the intent was to assign and compare in this statement. So when you just compare you get a warning. So you can fix that by hand if needed, or maybe it got fixed? 

Andrew Fish





On Jul 1, 2011, at 7:02 PM, egon@ragequ.it wrote:

Hi Andrew,

Sorry, I was working on this late last night and totally forgot to apply those patches. With a freshly updated copy of the source, the MdePkg patch applies successfully, but the Intel framework one does not:

$ patch -p0 <IntelFrameworkModulePkg.patch 
patching file IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
Reversed (or previously applied) patch detected!  Assume -R? [n] ^C

The error in the MdePkg previously has been resolved by that patch, but I'm now getting some linker errors:

ld: illegal text reloc to _NullSeg from /Users/x/Projects/EFI/edk2_take5/Build/Emulator/DEBUG_XCLANG/X64/MdePkg/Library/BaseLib/BaseLib/OUTPUT/BaseLib.lib(Thunk16.obj) in _16GdtrBase for architecture x86_64
ld: illegal text reloc to _NullSeg from /Users/x/Projects/EFI/edk2_take5/Build/Emulator/DEBUG_XCLANG/X64/UnixPkg/Library/UnixBaseLib/UnixBaseLib/OUTPUT/BaseLib.lib(Thunk16.obj) in _16GdtrBase for architecture x86_64

Full build here: http://pastebin.com/Uw0nfvdz

Any ideas?

Thanks

PS. Resent this to the list as I accidentally replied directly

On 02/07/2011, at 1:27 AM, Andrew Fish wrote:


On Jul 1, 2011, at 3:05 AM, egon@ragequ.it wrote:

Hi Andrew,

Thanks very much for the quick and detailed response. I've tried following these instructions but had no luck building the EmulatorPkg or UnixPkg. llvm + clang built fine.

I modified my Conf/target.txt[1] with what I thought were the correct options. This seems to work as expected as the new clang build is used in building the EmulatorPkg[2] and UnixPkg[3] which both fail with similar errors. I also had to s/FatPkg/FatBinPkg/g in EmulatorPkg/EmulatorPkg.d* to get past a file not found error initially, as there is no FatPkg/ in my checked out source.


Sorry the source to the FatPkg is in a separate project. https://edk2-fatdriver2.svn.sourceforge.net/svnroot/edk2-fatdriver2/trunk/FatPkg/
I had included the source version so there would be source level debug for everything.

I can continue to work with the 32-bit environment I built successfully last night with the Xcode toolchain (after compiling MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c without -Werror to avoid the "comparison is always true due to limited range of data type" warning) and move to the 64-bit environment when I can successfully build it, considering the 64-bit clang build is in a state of flux, but I'm happy to try any other suggestions if you have them.


The error looks like the it is the patch I've submitted, but has not yet been accepted to the MdePkg.
<MdePkg.patch>

You may also need to patch the IntelFramworkModulePkg:

<IntelFrameworkModulePkg.patch>

Good Luck

Thanks again for your help.

[1] Conf/target.txt - http://pastebin.com/ysYEmtLP
[2] EmulatorPkg build - http://pastebin.com/cvwkjvtW (32-bit) & http://pastebin.com/bz4hZPTY (64-bit)
[3] UnixPkg build - http://pastebin.com/R3J46ufD (64-bit)

On 01/07/2011, at 1:54 AM, Andrew Fish wrote:

egon,

Sorry I've not yet got to posting clang instructions. To get X64 support you need to use TOT open source clang.  TOT should work, but my instructions use the revision I've been using.

0) Pick a place to build clang.

1) Check out llvm:
svn co -r 132737 http://llvm.org/svn/llvm-project/llvm/trunk llvm

2) Check out clang:
cd llvm/tools
svn co -r 132737 http://llvm.org/svn/llvm-project/cfe/trunk clang

3) Build clang
cd ..
./configure --enable-optimized --disable-assertions --enable-targets=x86,x86_64
make -j4


These instructions assume you have done the following from your $(WORKSPACE) directory, i.e where you download the edk2 code:
. Conf/BuildEnv.sh BaseTools
This copies BaseTools/Conf/tools_def.template to Conf/tools_def.txt

4) Merge XCLANG settings from https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools/Conf/tools_def.template to your Conf/tools_def.txt.
This should get merged into the edk2 at some point, not in my control.

5) Edit Conf/tools_def.txt to point to the location of the clang build.
#
# Change to the location clang was built
#
DEFINE CLANG_BIN = /usr/bin/

We are moving development over to the EmulatorPkg so you may want to give that a try.  You can build and debug from Xcode using this project: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Xcode/xcode_project32/xcode_project.xcodeproj.  You can build from the command line and debug with gdb via:
cd  EmulatorPkg
./build.sh -a IA32
./build.sh -a IA32 run

For X64 it would be:
cd  EmulatorPkg
./build.sh
./build.sh  run

or

https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2/EmulatorPkg/Unix/Xcode/xcode_project64/xcode_project.xcodeproj/

Sorry we have not updated the Wiki yet. We just renamed EmulatorPkg yesterday, and there are some pending patches that have been submitted, but not committed that are required to fix clang build breaks. You can see the patches to fix clang build breaks on the edk2-devel mailing list. You don't need all of the patches, just the MdePkg and I think there may be one in IntelFrameworkModulePkg.

Thanks,

Andrew Fish





On Jun 30, 2011, at 8:18 AM, egon@ragequ.it wrote:

Woops, the issue with the 32-bit version was my own stupid fault - I had mistakenly changed the UnixPkg.fdf to point at the X64 GccShell. After changing it back and rebuilding I can successfully run the emulator in 32-bit mode.

The issues with the 64-bit build still remain.

Thanks,
egon.

PS. I get the same timestamp warnings with the 32-bit version that now runs fine, so they may not be a problem.

On 01/07/2011, at 1:01 AM, egon@ragequ.it wrote:

Hi,

I'm having some issues building EDKII on Mac OS X 10.6.8, on an iMac (Core i7). I'm trying to get everything built targeted for X64, using the Xcode 4 beta to build (as that's what I've got on my main development machine for Cocoa development). I've previously tried to use a cross-compiler version of GCC build using the mingw script, but I had less success with that. I've hacked around with so much stuff that I've just started with a fresh copy of the source to make sure I haven't created any issues myself haha..

I installed mtoc as per the instructions on the wiki, however it crashed when trying to convert binaries with an error about there not being an x64 section (threw the error then segfaulted). I compiled the new cctools-800 version (the build process was slightly different and I needed to download and build ld64 and copy libprunetrie.a and some headers out of that build first). Once I had mtoc working, attempting to build using the UnixPkg/build64.sh script I get a bunch of errors[1]. I tried messing around with the pragma options and didn't really get anywhere. From reading the commit messages I noticed that the clang stuff is quite new, anybody know what's going on here?

Following this I tried modifying the shell script to use the XCODE32 rather than XCLANG for UNIXPKG_TOOLS (UNIXPKG_TOOLS=XCODE32). I'm still very new to this environment and I haven't quite got my head around it, so I'm not sure if there is a specific reason for using clang. This builds fine[2] with the only potential issue being the `cp` error at the end, but that appears to be because I'm using XCODE32 for both TARGET_TOOLS and UNIXPKG_TOOLS.

When I attempt to run the emulator  as per the instructions on the wiki I get a number of warnings about timestamps and an EXC_BAD_ACCESS[3] - an example of the timestamps mentioned is as follows:
-rwxr-xr-x  1 x  staff  160776  1 Jul 00:29 /Users/x/Projects/EFI/edk2/Build/UnixX64/DEBUG_XCODE32/X64/SecMain
-rw-r--r--  1 x  staff  280320  1 Jul 00:30 /Users/x/Projects/EFI/edk2/Build/UnixX64/DEBUG_XCODE32/X64/UnixPkg/Library/UnixBaseLib/UnixBaseLib/OUTPUT/BaseLib.lib

I'm not sure if the timestamp differences are indicative of the problem that is causing the crash.

I can build targeted for 32-bit fine[4], and when I run it gets much further[5] (I even get the X11 window opening with the TianoCore logo etc), but then crashes with an ASSERT() error[6]. Reading the code comments indicates that this means my architecture is unsupported. Is that correct?

I need to get a build environment targeting X64 working, but if I'm fighting a losing battle here I can try it on a Linux or Windows VM. Can anybody point me in the right direction to figure out what the problem with my 64-bit build is?

Thanks!


[1] Build with clang errors: http://pastebin.com/cySYFQqw
[2] Successful build with XCODE32: http://pastebin.com/LbgS08qk
[3] Emulator run: http://pastebin.com/fm2z3irW
[4] Successful build with default build.sh: http://pastebin.com/kGREBWbL
[5] Run 32-bit: http://pastebin.com/70wGCBjZ
[6]: ASSERT!: /Users/x/Projects/EFI/edk2/MdeModulePkg/Core/Dxe/Image/Image.c (1439): (((Image->Machine) == 0x014C) || ((Image->Machine) == 0x0EBC))


------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
edk2-buildtools-devel mailing list
edk2-buildtools-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-buildtools-devel




------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel