Bug 62409

Summary: The cross build in rpm 4.0.4 is wrong
Product: [Retired] Red Hat Linux Reporter: hjl
Component: rpm-buildAssignee: Jeff Johnson <jbj>
Status: CLOSED WORKSFORME QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 7.1CC: petersen
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-10 14:24:05 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
A patch
none
A new patch.
none
A patch to get rid of ldd. none

Description hjl 2002-03-31 09:14:08 UTC
4.0.4 uses --host=%{_host} --target=%{_target_platform}
for %configure. It doesn't work with

# rpm --target=mipsel -ba ...

on Linux/x86. When I use "--target=mipsel", I want to
build a binary for mipsel, which means it runs on mipsel.
In that sense, the host is mipsel.

Comment 1 hjl 2002-03-31 09:15:06 UTC
Created attachment 51544 [details]
A patch

Comment 2 Jens Petersen 2002-04-10 03:22:16 UTC
Would "--host=%{_host} --build=%{_build}" be sufficient for you?
Is --target needed in general?  (cf bug 58468.)

Comment 3 Jens Petersen 2002-04-10 03:25:23 UTC
Btw when cross-building from linux are the macros in
/usr/lib/rpm/macros?  (For native building the macros are in
/usr/lib/rpm/*-linux/macros.)

Comment 4 hjl 2002-04-10 21:40:03 UTC
For most parts,  "--host=%{_target_platform} --build=%{_build}"
should work. Except for toolchain, --target is not used at all or it
should be the same as --host.


Comment 5 Jens Petersen 2002-04-12 07:14:13 UTC
What is wrong with "--host=%{_host}"?

Comment 6 Jens Petersen 2002-04-12 07:25:07 UTC
%{_target} and %{_host} are defined to be the same in "macros",
but %{_target_platform} is slightly different: it contains %{_vendor}
instead of %{_target_vendor}.  (ie redhat instead of pc ;-)

Comment 7 hjl 2002-04-12 16:17:03 UTC
When you do

# rpm --target=mipsel ...

%{_target} and %{_host}  will be different.

Comment 8 Jens Petersen 2002-04-15 07:55:41 UTC
In fact %{_target} and %{_host} seem to be different often by
default too. At least on my box, they expand to i386-pc-linux-gnu
and i686-pc-linux-gnu respectively, when building an i386 rpm.

While this doesn't seem too bad, it can confuse
some scripts into thinking it is a cross-build: eg
the Glasgow Haskell Compiler's (http://haskell.org/ghc/)
configure script does a check to make sure that host and target are
equal.


Comment 9 Jens Petersen 2002-04-15 08:08:51 UTC
hjl, do you have any particular package in mind?

It seems to me there are two possibilities:
1) just have "--build=%{_build} --host=%{_host}" in %configure
and then use:

  %configure --target=%{_target}

when building a cross toolchain package

2) have "--build=%{_build} --host=%{_host} --target=%{_target}",
though this may break some packages.

Comment 10 Jeff Johnson 2002-04-15 13:35:08 UTC
Designing %configure to be able to pass arguments
to "the Glasgow Haskell Compiler" correctly is silly,
there's no reason in the world why that package *has*
to use %configure.

Ditto any other package that thinks it's cross compiling
because of "pc" or "i386" != "i686" madnesss.

I see little reason for adding --build explicitly.
AFAIK, only a Candian cross compile, i.e. --build
is neither of --host or --target, needs/uses that
distinction. Yes, there are myriad and deeply twisted
pathways through configure that might make use of --build
if set.

Comment 11 Jens Petersen 2002-04-16 01:33:44 UTC
GHC was just an example of a package that breaks when both --host
and --target are specified.  A mass rebuild of the distribution
needs to be done to confirm that having both --host and --target
doesn't cause any problems for packages in the distribution.

The pc vs redhat vendor "madness" is nothing package specific, it is
common to all autoconf generated config script sets.

As was already discussed in bug 58468, if --host is specified,
then --build should be too, to avoid an annoying warning message
from configure.

Oh, yes, there is another possibility, which I'm perfectly fine
with: not specifying --build, --host, and --target at all.  That
would work just fine for everything except cross-compiling. ;-)

But let's do a mass rebuild of the distro with --build --host and
--target and if there are no problems, then I think it will make
everyone happy.

Comment 12 Jeff Johnson 2002-04-16 13:22:02 UTC
I'm perfectly happy invoking configure with
no arguments almost everywhere. However, that
does not plant the all-important ...-redhat-...
brand on the file system. <shrug>

Comment 13 Jens Petersen 2002-05-20 08:19:35 UTC
As I finally reported now under bug 58468, the --target configure
option causes target_alias to get prefixed to bindir filenames
during "make install".  However this can be solved by adding
--program-prefix=%{?_program_prefix:%{_program_prefix}}
to %configure too.

Ie I believe the following form is acceptable for both native and
cross packaging.

  CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
  CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
  FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \
  ./configure --host=%{_host} --build=%{_build} \\\
	--target=%{_target_platform} \\\
	--program-prefix=%{?_program_prefix:%{_program_prefix}} \\\
 	--prefix=%{_prefix} \\\
	--exec-prefix=%{_exec_prefix} \\\
	--bindir=%{_bindir} \\\
	--sbindir=%{_sbindir} \\\
	--sysconfdir=%{_sysconfdir} \\\
	--datadir=%{_datadir} \\\
	--includedir=%{_includedir} \\\
	--libdir=%{_libdir} \\\
	--libexecdir=%{_libexecdir} \\\
	--localstatedir=%{_localstatedir} \\\
	--sharedstatedir=%{_sharedstatedir} \\\
	--mandir=%{_mandir} \\\
	--infodir=%{_infodir}


Comment 14 hjl 2002-05-20 15:17:51 UTC
Created attachment 58014 [details]
A new patch.

Comment 15 hjl 2002-05-20 15:19:00 UTC
I uploaded a new patch. Also rpm uses ldd to get dependencies. It certainly
won't work with cross build. I will upload another patch.

Comment 16 hjl 2002-05-20 15:19:47 UTC
Created attachment 58015 [details]
A patch to get rid of ldd.

Comment 17 Jeff Johnson 2002-05-20 15:44:12 UTC
FWIW find-requires in rpm-4.1 uses objdump, not ldd,
and skips the (unnecessary IMHO) dependencies on the
ld-linux.so.2 interpreter.

Comment 18 hjl 2002-05-20 15:49:52 UTC
I have found the interpreter dependency useful in some cases. In
theory, the name of ld.so can change in the future. Also it may be
different from cpu to cpu.

Comment 19 Jeff Johnson 2002-05-20 15:52:29 UTC
All valid points, but that still doesn't mean
that the interpreter needs to be tracked with
package dependencies explicitly.

Comment 20 Jens Petersen 2002-07-08 08:29:33 UTC
BTW /usr/lib/rpm/redhat/macros in redhat-rpm-config now defines
%configure to use --host --build --target --program-prefix options
as above.

Comment 21 Jeff Johnson 2004-10-10 14:24:05 UTC
All issues I see here are either fixed, or problems
with other tools like automake.