public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [RFC] [PATCH] lib32: Add support for linking 32bit programs	on 64bit
Date: Wed, 29 Mar 2017 11:12:50 +0200	[thread overview]
Message-ID: <20170329091250.GC7089@rei.lan> (raw)
In-Reply-To: <1888940677.16511157.1490776585392.JavaMail.zimbra@redhat.com>

Hi!
> > * Configure test if compiler supports -m32
> >   TODO: Does 32bit compiler accept -m32?
> >         If so, we should fail the test on 32bit
> > 	platforms by default.
> > 
> > * The directory lib32 contains symlinks of minimal set of sources
> >   needed to link newlib testcase + Makefile.
> > 
> > * The testcases.mk builds 32bit library as well if
> >   32bit compiler was installed (-m32 configure test was succesful)
> > 
> > * And finally the env_post.mk switches between lib and lib32 depeding
> >   on if -m32 was passed in the CFLAGS
> > 
> 
> One issue I ran into is that configure checks can vary
> between default and -m32. Here's one exception from RHEL5.6:
> 
> # cat 1.c 
> int main(void) {
>         int i = 0;
>         return __sync_add_and_fetch(&i, 1);
> }
> 
> # gcc 1.c 
> # gcc -m32 1.c 
> /tmp/ccwrlcJi.o: In function `main':
> 1.c:(.text+0x27): undefined reference to `__sync_add_and_fetch_4'
> collect2: ld returned 1 exit status

Right, we would have to check for atomic operations with -m32 as well.

I guess that we can add -DUSE_M32 into the lib32/Makefile and add a few
ifdefs into the tst_atomic.h something as:

#if (defined(USE_M32) && HAVE_SYNC_AND_FETCH32 == 1) || \
    (!defined(USE_M32) && HAVE_SYNC_AND_FETCH == 1)
...
#elif ...
...

> > TODO: Check if LTP works with -m32 in CFLAGS passed to configure as well
> 
> This fails for me on RHEL7:
> 
> # make
> make[1]: Entering directory `/root/ltp/lib/newlib_tests'
> gcc -m32 -g -O2 -fno-strict-aliasing -pipe -Wall -W -Wold-style-definition -W -Wall  -I../../include -I../../include -I../../include/old/   -L../../lib32  test14.c   -lltp -o test14
> /tmp/ccPZUDSr.o: In function `cleanup':
> /root/ltp/lib/newlib_tests/test14.c:31: undefined reference to `safe_fopen'
> /root/ltp/lib/newlib_tests/test14.c:32: undefined reference to `safe_socket'
> collect2: error: ld returned 1 exit status
> make[1]: *** [test14] Error 1
> make[1]: Leaving directory `/root/ltp/lib/newlib_tests'
> make: *** [all] Error 2

This is likely because we try to link against lib32 since -m32 is passed
in CFLAGS but lib32/ directory links only subset of the C sources. I
would like to disable all the lib32 machinery either when we run on
32bit machine or if -m32 was passed to the configure and use lib32 only
in a case that we run on 64 bit machine and want to link 32 bit binary.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2017-03-29  9:12 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-28 10:01 [LTP] [RFC] [PATCH] lib32: Add support for linking 32bit programs on 64bit Cyril Hrubis
2017-03-28 14:55 ` Richard Palethorpe
2017-03-28 15:33   ` Cyril Hrubis
2017-03-28 15:46     ` Cyril Hrubis
2017-03-29  9:37       ` Richard Palethorpe
2017-03-29  8:36 ` Jan Stancek
2017-03-29  9:12   ` Cyril Hrubis [this message]
2017-03-29 12:48 ` Richard Palethorpe
2017-03-29 14:56   ` Richard Palethorpe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170329091250.GC7089@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox