Opened 10 years ago

Closed 9 years ago

Last modified 9 years ago

#8266 closed Bugs (fixed)

context library don't compile for Mac OSX universal binary

Reported by: Serguei E. Leontiev <leo@…> Owned by: olli
Milestone: To Be Determined Component: context
Version: Boost 1.53.0 Severity: Problem
Keywords: mac osx universal binary Cc: leo@…

Description

Message:

:info:build     
:info:build darwin.compile.c++ bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-x86/pch-off/threading-multi/unsupported.o
:info:build 
:info:build     "/usr/bin/clang++"  -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -dynamic -gdwarf-2 -fexceptions -fPIC -arch i386 -arch x86_64  -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_DYN_LINK=1 -DNDEBUG  -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-x86/pch-off/threading-multi/unsupported.o" "libs/context/src/unsupported.cpp"
:info:build 
:info:build libs/context/src/unsupported.cpp:7:2: error: "platform not supported"
:info:build #error "platform not supported"
:info:build  ^
:info:build 1 error generated.

Attachments (7)

patch-libs-context-130308-0.diff (2.1 KB ) - added by Serguei E. Leontiev <leo@…> 10 years ago.
workaround for build universal binary context library
b2-trunk-x86-32_64-example.log (24.5 KB ) - added by Serguei E. Leontiev <leo@…> 10 years ago.
patch_macosx_context_ppc.patch (35.8 KB ) - added by marco.serantoni@… 9 years ago.
Adding PPC32 and PPC64 for universal binary
patch_macosx_context_ppc_v2.patch (36.6 KB ) - added by marco.serantoni@… 9 years ago.
i missed jump_combined_sysv_macho_gas.S , sorry
patch_macosx_context_ppc_v2.2.patch (36.6 KB ) - added by marco.serantoni@… 9 years ago.
i missed jump_combined_sysv_macho_gas.S , sorry
boost_context_combined.patch (35.7 KB ) - added by marco.serantoni@… 9 years ago.
Patch for developer tree for combined option
bind_processor_darwin.cpp (752 bytes ) - added by marco.serantoni@… 9 years ago.
(for performance)

Download all attachments as: .zip

Change History (37)

by Serguei E. Leontiev <leo@…>, 10 years ago

workaround for build universal binary context library

comment:1 by Serguei E. Leontiev <leo@…>, 10 years ago

Reference to this bug on MacPorts sites: https://trac.macports.org/ticket/38298

comment:2 by olli, 10 years ago

please post the complete output of command in libs/context/example (for instance):

b2 toolset= ... --debug-building

I highly recommend to provide regression tests for 32bit Mac OS X on boost-trunk!

in reply to:  2 comment:3 by Ryan Schmidt <boost@…>, 10 years ago

Replying to olli:

please post the complete output of command in libs/context/example (for instance):

b2 toolset= ... --debug-building

You can find the full build log in the MacPorts ticket. If additional information is needed please let us know the exact commands you need us to run.

comment:4 by Andrew Fernandes <andrew@…>, 10 years ago

Hey, Olli - the problem is not the code, precisely, it is in the jamfile. The current 1.53.0 release does not handle OS X universal building when for <address-model>32_64. Thus bjam quits with an "unsupported.c" error.

The attached patch merely creates a pseudo-target for the universal address model as a stub, and includes the correct asm file for the given target during a universal build. It has been tested (on the MacPorts tracker) and shown to include the correct code.

The more important regression test actually needs to be done in boost-build, where universal architecture builds are tested, but that really needs to part of the core boost build, I think.

comment:5 by Serguei E. Leontiev <leo@…>, 10 years ago

Cc: leo@… added

comment:6 by Serguei E. Leontiev <leo@…>, 10 years ago

Replying to olli:

please post the complete output of command in libs/context/example (for instance): b2 toolset= ... --debug-building I highly recommend to provide regression tests for 32bit Mac OS X on boost-trunk!

I don't have 32bit Mac OS X. I add line "using darwin : : c++ -arch ... : : ;" to file "tools/build/v2/user-config.jam" before each build. See attachment "b2-trunk-x86-32_64-example.log" (25 Kbyte).

Before patch:
./bootstrap.sh --with-libraries=context --with-libraries=chrono

For both, modern Xcode 4.6, and old Xcode 3.6.2

user-config.jam: -arch i386
./b2 architecture=x86 address-model=32
OK

user-config.jam: -arch x86_64
./b2 architecture=x86 address-model=64
OK

user-config.jam: -arch i386 -arch x86_64
./b2 architecture=x86 address-model=32_64
Fail: #error "platform not supported"

user-config.jam: -arch ppc
./b2 architecture=power address-model=32
Fail: #error "platform not supported"

For old Xcode 3.2.6 only (Mac OS X 10.6.8 with Rosetta)

user-config.jam: -arch i386 -arch ppc
./b2 architecture=combined address-model=32
Fail: #error "platform not supported"

user-config.jam: -arch i386 -arch x86_64 -arch ppc
./b2 architecture=combined address-model=32
Fail: #error "platform not supported"

IMHO support universal binary has 2 level:

  1. Mandatory level, only support Intel code for Xcode 4.x for development new 64-bit applications and support 32-bit x86 application 38298;
  2. Impossible level, support both PowerPC and Intel code for Xcode 3.6 38339.

"patch-libs-context-130308-0.diff" addressed only for Intel code for Xcode 4.x. After patch:

user-config.jam: -arch i386 -arch x86_64
./b2 architecture=x86 address-model=32_64
OK

Examples seems working for both i386 and x86_64 architecture:

leom-3:example leo$ arch -x86_64 ../../../bin.v2/libs/context/example/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/exit
size: 0x58
main: call start_fcontext( & fcm, fc1, 0)
f1: entered
f1: call jump_fcontext( fc1, fc2, 0)
f2: entered
f2: call jump_fcontext( fc2, fc1, 0)
f1: return
leom-3:example leo$ arch -i386 ../../../bin.v2/libs/context/example/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/exit
size: 0x28
main: call start_fcontext( & fcm, fc1, 0)
f1: entered
f1: call jump_fcontext( fc1, fc2, 0)
f2: entered
f2: call jump_fcontext( fc2, fc1, 0)
f1: return
leom-3:example leo$ arch -x86_64 ../../../bin.v2/libs/context/example/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/jump
main: call start_fcontext( & fcm, fc1, 0)
f1: entered
f1: call jump_fcontext( fc1, fc2, 0)
f2: entered
f2: call jump_fcontext( fc2, fc1, 0)
f1: return
main: done
leom-3:example leo$ arch -i386 ../../../bin.v2/libs/context/example/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/jump
main: call start_fcontext( & fcm, fc1, 0)
f1: entered
f1: call jump_fcontext( fc1, fc2, 0)
f2: entered
f2: call jump_fcontext( fc2, fc1, 0)
f1: return
main: done
leom-3:example leo$ arch -x86_64 ../../../bin.v2/libs/context/example/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/transfer
2 + 7 == 9
5 + 6 == 11
main: done
leom-3:example leo$ arch -i386 ../../../bin.v2/libs/context/example/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/transfer
2 + 7 == 9
5 + 6 == 11
main: done

Regression test also not detect errors:

leom-3:test leo$ arch -i386 ../../../bin.v2/libs/context/test/test_context.test/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/test_context 
Running 8 test cases...

*** No errors detected
leom-3:test leo$ arch -x86_64 ../../../bin.v2/libs/context/test/test_context.test/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/test_context
Running 8 test cases...

*** No errors detected

For support PowerPC and universal binary with PowerPC also needed:

  1. Convert "{jump,make}_ppc{32,64}_sysv_elf_gas.S" to "{jump,make}_ppc{32,64}_sysv_macho_gas.S", i.e. convert syntax of comments, external symbol name decoration, syntax of register name and assembler expression;
  2. Compare Apple Mac OSX and IBM AIX documents about calling conventions, FPU and AltiVec usage;

But MacPorts users, may be, voted just disable "context" library for PPC.

Sorry for my best English

by Serguei E. Leontiev <leo@…>, 10 years ago

comment:7 by Serguei E. Leontiev <leo@…>, 10 years ago

P.S. MacPorts ticket about disabling PPC "context" library <https://trac.macports.org/ticket/38339>

comment:8 by olli, 9 years ago

Resolution: fixed
Status: newclosed

comment:9 by Ryan Schmidt <boost@…>, 9 years ago

Thanks. What revision in your Subversion repository fixed this, please?

in reply to:  9 comment:10 by olli, 9 years ago

Replying to Ryan Schmidt <boost@…>:

Thanks. What revision in your Subversion repository fixed this, please?

https://github.com/boostorg/context -> branch develop

Last edited 9 years ago by olli (previous) (diff)

comment:11 by marco.serantoni@…, 9 years ago

Build the static binary i've got an issue. Object file is created for a single architecture, then in the .a archive youll find only one architecture (in my case x86_64).

darwin.compile.asm is insensible to user directives so i've no way to add my "-arch i386 -arch x86_64" directives

So I've to patch my 1.54 release adding the options (cflags) to the darwin build. I Don't know if is the right way to do it, but i'm sure you could be something better.

modified file 'tools/build/v2/tools/gcc.jam'

--- tools/build/v2/tools/gcc.jam 2013-12-29 13:13:00 +0000 +++ tools/build/v2/tools/gcc.jam 2013-12-29 14:36:31 +0000 @@ -635,7 +635,7 @@

actions compile.asm {

  • "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) -D$(DEFINES) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"

+ "$(CONFIG_COMMAND)" $(LANG) $(OPTIONS) -D$(DEFINES) $(USER_OPTIONS) -I"$(INCLUDES)" -c -o "$(<)" "$(>)"

}

comment:12 by marco.serantoni@…, 9 years ago

You could do something better :)

comment:13 by olli, 9 years ago

You try to build for universal lib? Could you use the code from git master (contains code for MacOS X universal build -> untested) and build it with adress-model=32_64 and report the result, please?!

comment:14 by marco.serantoni@…, 9 years ago

git clone https://github.com/mirror/boost.git boost

macbook:boost marco$ ./b2 variant=release toolset=darwin threading=multi address-model=32_64 link=static context Performing configuration checks

  • arm : no (cached)
  • mips1 : no (cached)
  • power : no (cached)
  • sparc : no (cached)
  • x86 : yes (cached)

...found 14 targets... ...updating 3 targets... darwin.compile.c++ bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/unsupported.o libs/context/src/unsupported.cpp:7:2: error: "platform not supported" #error "platform not supported"

1 error generated.

"g++" -ftemplate-depth-128 -O3 -finline-functions -Wno-inline -Wall -gdwarf-2 -fexceptions -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/unsupported.o" "libs/context/src/unsupported.cpp"

...failed darwin.compile.c++ bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/unsupported.o... ...skipped <pbin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi>libboost_context.a(clean) for lack of <pbin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi>unsupported.o... ...skipped <pbin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi>libboost_context.a for lack of <pbin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi>unsupported.o... ...failed updating 1 target... ...skipped 2 targets...

in reply to:  14 comment:15 by olli, 9 years ago

Replying to marco.serantoni@…:

git clone https://github.com/mirror/boost.git boost

could you use https://github.com/boostorg instead, please

comment:16 by marco.serantoni@…, 9 years ago

git clone https://github.com/boostorg/boost.git boost_master git clone https://github.com/boostorg/build.git git clone https://github.com/boostorg/context.git git clone https://github.com/boostorg/inspect.git

As said the .o files are made only for x86_64 and not for i386 --

macbook:boost_master marco$ ./b2 variant=release toolset=darwin threading=multi address-model=32_64 link=static context -d+2 Performing configuration checks

  • symlinks supported : yes (cached)
  • hardlinks supported : yes (cached)
  • arm : no (cached)
  • mips1 : no (cached)
  • power : no (cached)
  • sparc : no (cached)
  • x86 : yes (cached)

darwin.compile.asm bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o

"g++" -x assembler-with-cpp -O3 -finline-functions -Wno-inline -Wall -gdwarf-2 -fexceptions -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/make_i386_x86_64_sysv_macho_gas.S"

darwin.compile.asm bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o

"g++" -x assembler-with-cpp -O3 -finline-functions -Wno-inline -Wall -gdwarf-2 -fexceptions -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/jump_i386_x86_64_sysv_macho_gas.S"

RmTemps bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a(clean)

rm -f "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a"

darwin.archive bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a

"/usr/bin/libtool" -static -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a" "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o" "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o"

macbook:boost_master marco$ file ./bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o ./bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o: Mach-O 64-bit object x86_64

comment:17 by marco.serantoni@…, 9 years ago

Same thing with develop branch.

git clone --branch develop https://github.com/boostorg/boost.git boost git clone --branch develop https://github.com/boostorg/build.git git clone --branch develop https://github.com/boostorg/inspect.git git clone --branch develop https://github.com/boostorg/context.git

macbook:boost marco$ ./b2 variant=release toolset=darwin threading=multi address-model=32_64 link=static context -d+2 Performing configuration checks

  • symlinks supported : yes (cached)
  • hardlinks supported : yes (cached)
  • arm : no (cached)
  • mips1 : no (cached)
  • power : no (cached)
  • sparc : no (cached)
  • x86 : yes (cached)

darwin.compile.asm bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o

"g++" -x assembler-with-cpp -O3 -finline-functions -Wno-inline -Wall -gdwarf-2 -fexceptions -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/make_i386_x86_64_sysv_macho_gas.S"

darwin.compile.asm bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o

"g++" -x assembler-with-cpp -O3 -finline-functions -Wno-inline -Wall -gdwarf-2 -fexceptions -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_SOURCE -DNDEBUG -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/jump_i386_x86_64_sysv_macho_gas.S"

RmTemps bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a(clean)

rm -f "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a"

darwin.archive bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a

"/usr/bin/libtool" -static -o "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a" "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o" "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o"

macbook:boost marco$ file bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/libboost_context.a: current ar archive random library macbook:boost marco$ file bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/jump_i386_x86_64_sysv_macho_gas.o: Mach-O 64-bit object x86_64 macbook:boost marco$ file bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/link-static/threading-multi/asm/make_i386_x86_64_sysv_macho_gas.o: Mach-O 64-bit object x86_64

comment:18 by anonymous, 9 years ago

hmm - I don't use Mac OS X (no access to it) and I'm not familiar how universal libs work internally. adding '-arch i386 -arch x86_64' fixes your problem? if yes then it should be added for the other boost libs too. if this is true I believe this is an issue of the boost.build system.

comment:19 by marco.serantoni@…, 9 years ago

In OSX you can compile for multiple platforms and the result is collapsed in a single object file/binary. To instruct the compiler to threat the file for multiple architectures you have to give -arch argument(s). I've solved propagating the user environment to the assembler that already contains the -arch that i need.

So the compiler elaborate the assembly and insert it in the two -arch sections.

Yes, this solves the issue.

by marco.serantoni@…, 9 years ago

Adding PPC32 and PPC64 for universal binary

comment:20 by marco.serantoni@…, 9 years ago

Sorry if i continue in this ticket.

I've ported the ppc_elf to ppc_match-o. I've tested the ppc32 but i'm unable to test the ppc64 side.

This patch was done on 1.54.0, but should be not problematic adding it to developer tree.

by marco.serantoni@…, 9 years ago

i missed jump_combined_sysv_macho_gas.S , sorry

by marco.serantoni@…, 9 years ago

i missed jump_combined_sysv_macho_gas.S , sorry

by marco.serantoni@…, 9 years ago

Patch for developer tree for combined option

comment:21 by marco.serantoni@…, 9 years ago

I've added the patch for the development tree does all correct on platforms that handles PPC/PPC64 (boost_context_combined.patch)

I've also added the arm platform that is available on the last releases of OSX.

All works correctly. To further test i've manually generated (on two different systems) those files, covering all the spectrum (i386, x86_64, PPC32, PPC64, arm)

10.9.1

macbook:boost_develop marco$ file "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/make_combined_sysv_macho_gas.o"
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/make_combined_sysv_macho_gas.o: Mach-O universal binary with 3 architectures
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/make_combined_sysv_macho_gas.o (for architecture i386)Mach-O object i386
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/make_combined_sysv_macho_gas.o (for architecture x86_64):	Mach-O 64-bit object x86_64
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/make_combined_sysv_macho_gas.o (for architecture armv4t):	Mach-O object arm

10.6.8

mini:boost_develop marco$ file "bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/jump_combined_sysv_macho_gas.o"
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/jump_combined_sysv_macho_gas.o: Mach-O universal binary with 4 architectures
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/jump_combined_sysv_macho_gas.o (for architecture i386)Mach-O object i386
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/jump_combined_sysv_macho_gas.o (for architecture ppc):Mach-O object ppc
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/jump_combined_sysv_macho_gas.o (for architecture x86_64):	Mach-O 64-bit object x86_64
bin.v2/libs/context/build/darwin-4.2.1/release/address-model-32_64/architecture-combined/link-static/threading-multi/asm/jump_combined_sysv_macho_gas.o (for architecture ppc64):	Mach-O 64-bit object ppc64

comment:22 by olli, 9 years ago

I've modified the patch - universal libraries are build with property address-model=32_64 (architecture x86 or power). Could you test the code in branch develop please?

comment:23 by marco.serantoni@…, 9 years ago

Olli, The issue there is that you have splitted x86/ppc, universal binaries are BOTH at least.

As you can see in the documentation: http://www.boost.org/doc/libs/1_55_0/doc/html/bbv2/reference.html

"The darwin toolset can generate so called "fat" binaries—binaries that can run support more than one architecture, or address mode. To build a binary that can run both on Intel and PowerPC processors, specify architecture=combined. To build a binary that can run both in 32-bit and 64-bit modes, specify address-model=32_64. If you specify both of those properties, a "4-way" fat binary will be generate."

The combined architecture exists and is to be implemented (PPC/x86).

In some cases, for example iPhone development, you could need to compile together x86 and ARM because the iPhone Emulator runs x86 binaries, the real iphone has an ARM processor. There is not an "architecture" already set, but the intention was have a pre-cooked meal :)

comment:24 by marco.serantoni@…, 9 years ago

Not Working for x86

macbook:boost_develop marco$ ./b2 architecture=x86 address-model=32_64 context -d+2 
Performing configuration checks

    - symlinks supported       : yes (cached)
    - hardlinks supported      : yes (cached)
Jamfile</Users/marco/Development/boost_develop/libs/context/build>.gas bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.o

    as -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/make_i386_x86_64_sysv_macho_gas.S"

Jamfile</Users/marco/Development/boost_develop/libs/context/build>.gas bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o

    as -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/jump_i386_x86_64_sysv_macho_gas.S"

darwin.link.dll bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/libboost_context.dylib

    "g++" -dynamiclib -Wl,-single_module -install_name "libboost_context.dylib"  -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/libboost_context.dylib" "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.o" "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o"      -headerpad_max_install_names -g -arch i386 -arch x86_64 

ld: warning: ld: warning: ignoring file bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.oignoring file bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o, file was built for unsupported file format ( 0xCF 0xFA 0xED 0xFE 0x07 0x00 0x00 0x01 0x03 0x00 0x00 0x00 0x01 0x00 0x00 0x00 ) which is not the architecture being linked (i386): bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o

macbook:boost_develop marco$ file bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o
bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o: Mach-O 64-bit object x86_64

comment:25 by marco.serantoni@…, 9 years ago

I was able to fix, passing thru the compiler with this changes:

macbook:context marco$ git diff

diff --git a/build/Jamfile.v2 b/build/Jamfile.v2
index 1e5b096..dee50db 100644
--- a/build/Jamfile.v2
+++ b/build/Jamfile.v2
@@ -513,8 +513,8 @@ alias asm_context_sources
 
 #X86 universal
 alias asm_context_sources
-   : [ make asm/make_i386_x86_64_sysv_macho_gas.o : asm/make_i386_x86_64_sysv_macho_gas.S : @gas ]
-     [ make asm/jump_i386_x86_64_sysv_macho_gas.o : asm/jump_i386_x86_64_sysv_macho_gas.S : @gas ]
+   : asm/make_i386_x86_64_sysv_macho_gas.S 
+     asm/jump_i386_x86_64_sysv_macho_gas.S
    : <address-model>32_64
      <architecture>x86
      <binary-format>mach-o

RESULT

macbook:boost_develop marco$ ./b2 architecture=x86 address-model=32_64 context  -d+2  
Performing configuration checks

    - symlinks supported       : yes (cached)
    - hardlinks supported      : yes (cached)
darwin.compile.asm bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.o

    "g++" -x assembler-with-cpp -O0 -fno-inline -Wall -g -dynamic -gdwarf-2 -fexceptions -fPIC -arch i386 -arch x86_64 -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_DYN_LINK=1 -DBOOST_CONTEXT_SOURCE -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/make_i386_x86_64_sysv_macho_gas.S"

darwin.compile.asm bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o

    "g++" -x assembler-with-cpp -O0 -fno-inline -Wall -g -dynamic -gdwarf-2 -fexceptions -fPIC -arch i386 -arch x86_64 -DBOOST_ALL_NO_LIB=1 -DBOOST_CONTEXT_DYN_LINK=1 -DBOOST_CONTEXT_SOURCE -I"." -c -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o" "libs/context/src/asm/jump_i386_x86_64_sysv_macho_gas.S"

darwin.link.dll bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/libboost_context.dylib

    "g++" -dynamiclib -Wl,-single_module -install_name "libboost_context.dylib"  -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/libboost_context.dylib" "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/make_i386_x86_64_sysv_macho_gas.o" "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/asm/jump_i386_x86_64_sysv_macho_gas.o"      -headerpad_max_install_names -g -arch i386 -arch x86_64 
macbook:boost_develop marco$ file bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/asm/make_i386_x86_64_sysv_macho_gas.o
bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/asm/make_i386_x86_64_sysv_macho_gas.o: Mach-O universal binary with 2 architectures
bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/asm/make_i386_x86_64_sysv_macho_gas.o (for architecture i386):	Mach-O object i386
bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32_64/architecture-x86/link-static/asm/make_i386_x86_64_sysv_macho_gas.o (for architecture x86_64):	Mach-O 64-bit object x86_64

comment:26 by anonymous, 9 years ago

OK - I ddn't know that MacOS X can put code for 4 architectures in one library - thx to you to fix it.
I've change the code in branch develop - I tried to reduce the selections in build/Jamfile.
I'm a little bit astonished that

[ make asm/make_i386_x86_64_sysv_macho_gas.o : asm/make_i386_x86_64_sysv_macho_gas.S : @gas ]

does not work.
Could you check that the library compiles for following configurations on MacOS X, please?

architecture=x86 address-model=32
architecture=x86 address-model=64
architecture=x86 address-model=32_64
architecture=power address-model=32
architecture=power address-model=64
architecture=power address-model=32_64
architecture=combined address-model=32
architecture=combined address-model=64
architecture=combined address-model=32_64

comment:27 by marco.serantoni@…, 9 years ago

It is a great idea the FAT binaries, it is not limited to 4, could have also more than 4 at time. Theorically could support x86/MIPS/MC98k/ARM/SPARC/POWERPC all together at expenses of size, i miss this features with /lib /lib64, one file N architectures ;) This is done from the compiler usually, that spawns N compiler one for each "-arch" and assemble all in a single .o or binary.

KO - x86/32
KO - x86/64
OK - x86/32_64
KO - power/32
KO - power/64 (indicated as x86 in build file)
OK - power/32_64
OK - combined/32
OK - combined/64
OK - combined/32_64

I've elaborated another patch to fix, you should avoid to use the [make ] and use the compiler to do the work. The issue with the x86/32 is referred to the label (probably 'as' doesn't like a label at the beginning of the row) Works if passing thru the compiler.

diff --git a/build/Jamfile.v2 b/build/Jamfile.v2
index 6c2a662..d7b5bde 100644
--- a/build/Jamfile.v2
+++ b/build/Jamfile.v2
@@ -143,8 +143,8 @@ alias asm_context_sources
    ;
 
 alias asm_context_sources
-   : [ make asm/make_ppc32_sysv_macho_gas.o : asm/make_ppc32_sysv_macho_gas.S : @gas ]
-     [ make asm/jump_ppc32_sysv_macho_gas.o : asm/jump_ppc32_sysv_macho_gas.S : @gas ]
+   : asm/make_ppc32_sysv_macho_gas.S
+     asm/jump_ppc32_sysv_macho_gas.S
    : <address-model>32
      <architecture>power
      <binary-format>mach-o
@@ -169,10 +169,10 @@ alias asm_context_sources
    ;
 
 alias asm_context_sources
-   : [ make asm/make_ppc64_sysv_macho_gas.o : asm/make_ppc64_sysv_macho_gas.S : @gas ]
-     [ make asm/jump_ppc64_sysv_macho_gas.o : asm/jump_ppc64_sysv_macho_gas.S : @gas ]
+   : asm/make_ppc64_sysv_macho_gas.S
+     asm/jump_ppc64_sysv_macho_gas.S
    : <address-model>64
-     <architecture>x86
+     <architecture>power
      <binary-format>mach-o
      <target-os>darwin
    ;
@@ -224,8 +224,8 @@ alias asm_context_sources
    ;
 
 alias asm_context_sources
-   : [ make asm/make_i386_sysv_macho_gas.o : asm/make_i386_sysv_macho_gas.S : @gas ]
-     [ make asm/jump_i386_sysv_macho_gas.o : asm/jump_i386_sysv_macho_gas.S : @gas ]
+   : asm/make_i386_sysv_macho_gas.S
+     asm/jump_i386_sysv_macho_gas.S
    : <address-model>32
      <architecture>x86
      <binary-format>mach-o
@@ -261,8 +261,8 @@ alias asm_context_sources
    ;
 
 alias asm_context_sources
-   : [ make asm/make_x86_64_sysv_macho_gas.o : asm/make_x86_64_sysv_macho_gas.S : @gas ]
-     [ make asm/jump_x86_64_sysv_macho_gas.o : asm/jump_x86_64_sysv_macho_gas.S : @gas ]
+   : asm/make_x86_64_sysv_macho_gas.S
+     asm/jump_x86_64_sysv_macho_gas.S
    : <address-model>64
      <architecture>x86
      <binary-format>mach-o

Example of error (x86/32)

mini:boost_develop marco$ ./b2 link=static architecture=x86 address-model=32 context
Performing configuration checks

    - symlinks supported       : yes (cached)
    - hardlinks supported      : yes (cached)
...found 17 targets...
...updating 4 targets...
Jamfile</Users/marco/Development/boost_develop/libs/context/build>.gas bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static/asm/make_i386_sysv_macho_gas.o
libs/context/src/asm/make_i386_sysv_macho_gas.S:59:suffix or operands invalid for `pop'

    as -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static/asm/make_i386_sysv_macho_gas.o" "libs/context/src/asm/make_i386_sysv_macho_gas.S"

...failed Jamfile</Users/marco/Development/boost_develop/libs/context/build>.gas bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static/asm/make_i386_sysv_macho_gas.o...
Jamfile</Users/marco/Development/boost_develop/libs/context/build>.gas bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static/asm/jump_i386_sysv_macho_gas.o
libs/context/src/asm/jump_i386_sysv_macho_gas.S:70:suffix or operands invalid for `jmp'

    as -o "bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static/asm/jump_i386_sysv_macho_gas.o" "libs/context/src/asm/jump_i386_sysv_macho_gas.S"

...failed Jamfile</Users/marco/Development/boost_develop/libs/context/build>.gas bin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static/asm/jump_i386_sysv_macho_gas.o...
...skipped <pbin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static>libboost_context.a(clean) for lack of <pbin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static>asm/make_i386_sysv_macho_gas.o...
...skipped <pbin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static>libboost_context.a for lack of <pbin.v2/libs/context/build/darwin-4.2.1/debug/address-model-32/architecture-x86/link-static>asm/make_i386_sysv_macho_gas.o...
...failed updating 2 targets...
...skipped 2 targets...

by marco.serantoni@…, 9 years ago

Attachment: bind_processor_darwin.cpp added

(for performance)

comment:28 by marco.serantoni@…, 9 years ago

I've able compile also the context/performance with the bind_processor_darwin.cpp and this

i had to remove the RT library that is not present/needed in OSX I don't know an elegant way to make it optional ONLY for darwin.

diff --git a/performance/Jamfile.v2 b/performance/Jamfile.v2
index 108c0e1..718435c 100644
--- a/performance/Jamfile.v2
+++ b/performance/Jamfile.v2
@@ -17,7 +17,7 @@ project boost/context/performance
     : requirements
       <library>/boost/context//boost_context
       <link>static
-      <linkflags>"-lrt" 
+      <linkflags>"" 
       <threading>single
     ;
 
@@ -57,6 +57,12 @@ alias sources
    : <target-os>windows
    ;
 
+alias sources
+   : performance.cpp
+     bind_processor_darwin.cpp
+   : <target-os>darwin
+   ;
+
 explicit sources ;
 
 exe performance

comment:29 by marco.serantoni@…, 9 years ago

Your last commit

OK - x86/32
OK - x86/64
OK - x86/32_64
OK - power/32
OK - power/64 (indicated as x86 in build file)
OK - power/32_64
OK - combined/32
OK - combined/64
OK - combined/32_64

Could you add bind_processor_darwin.cpp in boost/performance ? Doesn't is perfect, but is the best thing that is possible to do on Darwin platform :)

comment:30 by marco.serantoni@…, 9 years ago

Is all ok, was as x86 indicated i mean ;)

Note: See TracTickets for help on using tickets.