We're working on setting up an environment to cross-compile a winelib application (initially from x86 linux to sparc solaris). To do this, we need a cross-compiling version of winebuild which will generate the assembly code for the target architecture instead of the build architecture.
I see two basic ways we can accomplish this. We could either use autoconf's --target flag to specify the target architecture, and then replace all of the "#ifdef __sparc__" statements in winebuild with "#ifdef __target_arch_sparc". I came across an autoconf macro (http://autoconf-archive.cryp.to/ac_create_target_h.html) that would generate the appropriate defines.
The other way we could approach the problem is to modify winebuild to always generate assembly code for all of the architectures, pushing the #ifdefs down into the .spec.c file.
I'm inclined to stick with the first option, since it looks like less work and less chance of introducing errors, but I wanted to run it by the list before starting work. Would a patch like this be accepted into wine? Do you know of any other gotchas we should be aware of?
Thanks, Eric
Eric Frias efrias@syncad.com writes:
I see two basic ways we can accomplish this. We could either use autoconf's --target flag to specify the target architecture, and then replace all of the "#ifdef __sparc__" statements in winebuild with "#ifdef __target_arch_sparc". I came across an autoconf macro (http://autoconf-archive.cryp.to/ac_create_target_h.html) that would generate the appropriate defines.
The other way we could approach the problem is to modify winebuild to always generate assembly code for all of the architectures, pushing the #ifdefs down into the .spec.c file.
I think the right way is to get rid of the #ifdefs, but not by pushing them into the .spec.c file but my making the target a run-time option. I've been meaning to do this for a while now, I was just waiting for someone to actually need that feature ;-)
Alexandre Julliard wrote:
I think the right way is to get rid of the #ifdefs, but not by pushing them into the .spec.c file but my making the target a run-time option. I've been meaning to do this for a while now, I was just waiting for someone to actually need that feature ;-)
Fantastic! Those ifdefs have been driving me crazy. After adding support in winebuild for hppa, I found the source code extremely difficult to follow. Cutting out most of the ifdefs should make it much more manageable.
So we could do something like this: Add a --target= option to both winegcc and winebuild. If present, winegcc would pass that option through to winebuild. The target parameter could be a standard cpu-mfr-opsys system triplet like config.guess generates. Without this --target option, the behavior is unchanged. If the --target=foo is present, we generate assembler code for the 'foo' architecture.
Additionally, we could set the default compiler to foo-gcc, linker to foo-ld, (and same for g++, nm, cpp, whatever else we use). These are the default filenames for cross-compilers, so I think it would make sense to use these when the target is specified. These could be overridden by command line args (there's already an --ld-cmd, so we could add --cc-cmd, --cxx-cmd, etc).
Eric