public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
* [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails
@ 2007-03-14 21:50 wcohen at redhat dot com
  2007-03-15 14:07 ` [Bug translator/4186] " wcohen at redhat dot com
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: wcohen at redhat dot com @ 2007-03-14 21:50 UTC (permalink / raw)
  To: systemtap

SystemTap generates a test to check the architecture of the target machine and
make sure that it matches. When doing cross compiling for the olpc machine the
kernel is a i586 architecture. systemtap_module_init has the following code in it:

    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,19)
    const char* machine = utsname()->machine;
    const char* release = utsname()->release;
    #else
    const char* machine = system_utsname.machine;
    const char* release = system_utsname.release;
    #endif
    if (strcmp (machine, "i686")) {
      _stp_error ("module machine mismatch (%s vs %s)", machine, "i686");
      rc = -EINVAL;
    }

when building for the olpc kernel the "i686" strings should be "i586". The
translator needs to figure out the architecture. It might be able to do this
from the arch in the directory name, like the following:

/usr/src/kernels/2.6.21-20070312.olpc1p.3eca75102a57502-i586

The make also need to build the module for the subarchitecture.

-- 
           Summary: Cross compiling for sub architectures (e.g. i586 target
                    i686 host) fails
           Product: systemtap
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: translator
        AssignedTo: systemtap at sources dot redhat dot com
        ReportedBy: wcohen at redhat dot com


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] Cross compiling for sub architectures (e.g. i586 target i686 host) fails
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
@ 2007-03-15 14:07 ` wcohen at redhat dot com
  2007-03-15 18:45 ` fche at redhat dot com
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wcohen at redhat dot com @ 2007-03-15 14:07 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From wcohen at redhat dot com  2007-03-15 14:07 -------
Created an attachment (id=1618)
 --> (http://sourceware.org/bugzilla/attachment.cgi?id=1618&action=view)
disable architecture check in generated module

The translate.diff patch disables the architecture check on the generated code.
This has been used by olpc developer Chris Ball with some success. However,
this could cause problems because it could allow illegal instructions to be in
the module. For example compile on i686 machine and generate conditional moves
that are not available on the i586 platform.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] Cross compiling for sub architectures (e.g. i586 target i686 host) fails
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
  2007-03-15 14:07 ` [Bug translator/4186] " wcohen at redhat dot com
@ 2007-03-15 18:45 ` fche at redhat dot com
  2007-03-20 16:56 ` wcohen at redhat dot com
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: fche at redhat dot com @ 2007-03-15 18:45 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From fche at redhat dot com  2007-03-15 18:44 -------
Disabling *that* architecture check is not a plausible fix to this problem.

The translator in general does not know how to invoke cross-compilers (or
the equivalent: force subarchitecture-specific CFLAGS).  The module that
managed to be run with this patch might work because of coincidence.  One
has to examine the compiler command line to see how it was really built.

We lack a command line option to set the session.architecture value, like
we already set session.release from -r.  I suggest "-a ARCH", or perhaps
as a suffix to the -r argument.

In any case, that's just a first step.  The hard part is interfacing properly
with a kernel-devel & kernel-debuginfo tree for an arbitrary architecture,
and invoking all the cross-compilers (or just non-native options) as needed.


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] Cross compiling for sub architectures (e.g. i586 target i686 host) fails
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
  2007-03-15 14:07 ` [Bug translator/4186] " wcohen at redhat dot com
  2007-03-15 18:45 ` fche at redhat dot com
@ 2007-03-20 16:56 ` wcohen at redhat dot com
  2007-03-20 20:40 ` wcohen at redhat dot com
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wcohen at redhat dot com @ 2007-03-20 16:56 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From wcohen at redhat dot com  2007-03-20 16:56 -------
Yes, I agree entirely. The translate.diff is not a fix for the problem, as
mentioned in the previous comment incorrect code for the target kernel could be
generated.

There are two levels of cross compiling:

1) generating for a subarchecture, e.g. i586 target i686 host
2) cross compiling, e.g. arm target with i686 host

The first is a bit simpler as it uses the host compiler with options to select
the appropriate subarchitecture. The cross compile is more complicated but would
be of interest to developers working on embedded Linux systems, e.g. Nokia N800.

Looking through the spec file for the kernel there is some code in BuildKernel()
that adjusts the build based on the target.




-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] Cross compiling for sub architectures (e.g. i586 target i686 host) fails
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
                   ` (2 preceding siblings ...)
  2007-03-20 16:56 ` wcohen at redhat dot com
@ 2007-03-20 20:40 ` wcohen at redhat dot com
  2007-04-10 18:32 ` wcohen at redhat dot com
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wcohen at redhat dot com @ 2007-03-20 20:40 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From wcohen at redhat dot com  2007-03-20 20:40 -------
It looks like the correct code subarchitecture code should be
generated.  An automated grep of the files in the linux kernel
directory turned up the following line:

./arch/i386/Makefile.cpu:cflags-$(CONFIG_M586)          += -march=i586

One of the problems observed in the stap translator code is that
tapsets.cxx:query_module() assumes that if the vmlinux file is i386
that it should be i686. It could be i586 or i486. There is a comment
in there about this:

      // Validate the machine code in this elf file against the
      // session machine.  This is important, in case the wrong kind
      // of debuginfo is being automagically processed by elfutils.
      // Unfortunately, while we can tell i686 apart from x86-64,
      // we can't help confusing i586 vs i686 (both EM_386).


The translator should be able to do a better job determine the target
architecture.  Couldn't this information be obtained from .config and
Makefile in kernel-devel?

For cross compiling http://lwn.net/Articles/21823/ has comments about
building modules and cross-compile. Should be able to do the following
when building the systemtap module:

CROSS_COMPILE=ppc_4xx- make -C ...


-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] Cross compiling for sub architectures (e.g. i586 target i686 host) fails
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
                   ` (3 preceding siblings ...)
  2007-03-20 20:40 ` wcohen at redhat dot com
@ 2007-04-10 18:32 ` wcohen at redhat dot com
  2009-08-05 20:08 ` [Bug translator/4186] cross-architecture compilation fche at redhat dot com
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: wcohen at redhat dot com @ 2007-04-10 18:32 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From wcohen at redhat dot com  2007-04-10 19:32 -------
Thinking about this some more. The way that c_unparser::emit_module_init()
should check for machine really should be determined by build/make of the
module. There shouldn't be a reason for someone to explicitly set the
architecture. The "-march=" doesn't set a single define for this. Thinking of
having is a function/define in the run time library that generates the
appropriate machine string based on __i486__, __i586__, ___i686___, etc.

static inline char *_stp_target_machine_arch()
{
#if defined(__i386__)
return "i386";
#elseif defined(__i486__)
return "i486";
...
#else
#error "cannot determine target arch"
#endif
}

generate code for for test something like this:

 if (strcmp (machine, _stp_target_machine_arch())) {
  _stp_error ("module machine mismatch (%s vs %s)", machine,
   _stap_target_machine_arch());
   rc = -EINVAL;
 }



-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] cross-architecture compilation
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
                   ` (4 preceding siblings ...)
  2007-04-10 18:32 ` wcohen at redhat dot com
@ 2009-08-05 20:08 ` fche at redhat dot com
  2009-08-05 20:18 ` roland at gnu dot org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: fche at redhat dot com @ 2009-08-05 20:08 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From fche at redhat dot com  2009-08-05 20:08 -------
Changing summary line, as this was just a special case of a real
user need to perform cross-arch compilation of systemtap scripts.
Presumably this needs to work with -r /build/trees only as opposed
to rpm-installed packages.  It may be enough to pass

CROSS_COMPILE=target-triplet-

in buildrun.cxx's makefile generation phase.


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Cross compiling for sub     |cross-architecture
                   |architectures (e.g. i586    |compilation
                   |target i686 host) fails     |


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] cross-architecture compilation
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
                   ` (5 preceding siblings ...)
  2009-08-05 20:08 ` [Bug translator/4186] cross-architecture compilation fche at redhat dot com
@ 2009-08-05 20:18 ` roland at gnu dot org
  2009-08-24 14:38 ` fche at redhat dot com
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: roland at gnu dot org @ 2009-08-05 20:18 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From roland at gnu dot org  2009-08-05 20:18 -------
Perhaps it is enough to document the cross-setup for this.
That is, advise that to use -r /cross/kernel/build you should first create
/cross/kernel/build/GNUmakefile containing:

CROSS_COMPILE=cross-tool-prefix-
include Makefile

This will make all "make -C /cross/kernel/build" of any kind automagically dtrt.
IMHO it seems reasonable to consider that part of the setup of arranging to
cross-build kernel modules at all, systemtap aside.

-- 


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] cross-architecture compilation
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
                   ` (6 preceding siblings ...)
  2009-08-05 20:18 ` roland at gnu dot org
@ 2009-08-24 14:38 ` fche at redhat dot com
  2009-08-24 21:57 ` mjw at redhat dot com
  2009-08-25  0:42 ` fche at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: fche at redhat dot com @ 2009-08-24 14:38 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From fche at redhat dot com  2009-08-24 14:37 -------
commit 1392896

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] cross-architecture compilation
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
                   ` (7 preceding siblings ...)
  2009-08-24 14:38 ` fche at redhat dot com
@ 2009-08-24 21:57 ` mjw at redhat dot com
  2009-08-25  0:42 ` fche at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: mjw at redhat dot com @ 2009-08-24 21:57 UTC (permalink / raw)
  To: systemtap


------- Additional Comments From mjw at redhat dot com  2009-08-24 21:56 -------
There are still some issues on i?86. Some places are confused about i386 versus
i686 now. s.architecture is now "squashed" to i386, but that means we no longer
read <prefix>/share/systemtap/tapset/i686 (we look for i386 now).

Some other testsuite issues:
- testsuite/systemtap.base/cmd_parse.exp cmd_parse16 uses "uname -m", but that
is i686 while we expect i386.
- testsuite/systemtap.base/preprocessor.exp also uses "uname -m" to test the %(
arch )% setting.

Almost all uses of uname -m should probably be -i. Double check the uses of %(arch)%

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug translator/4186] cross-architecture compilation
  2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
                   ` (8 preceding siblings ...)
  2009-08-24 21:57 ` mjw at redhat dot com
@ 2009-08-25  0:42 ` fche at redhat dot com
  9 siblings, 0 replies; 11+ messages in thread
From: fche at redhat dot com @ 2009-08-25  0:42 UTC (permalink / raw)
  To: systemtap



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|systemtap at sources dot    |fche at redhat dot com
                   |redhat dot com              |
             Status|REOPENED                    |ASSIGNED


http://sourceware.org/bugzilla/show_bug.cgi?id=4186

------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-08-25  0:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-14 21:50 [Bug translator/4186] New: Cross compiling for sub architectures (e.g. i586 target i686 host) fails wcohen at redhat dot com
2007-03-15 14:07 ` [Bug translator/4186] " wcohen at redhat dot com
2007-03-15 18:45 ` fche at redhat dot com
2007-03-20 16:56 ` wcohen at redhat dot com
2007-03-20 20:40 ` wcohen at redhat dot com
2007-04-10 18:32 ` wcohen at redhat dot com
2009-08-05 20:08 ` [Bug translator/4186] cross-architecture compilation fche at redhat dot com
2009-08-05 20:18 ` roland at gnu dot org
2009-08-24 14:38 ` fche at redhat dot com
2009-08-24 21:57 ` mjw at redhat dot com
2009-08-25  0:42 ` fche at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).