Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #15897

Re: Writing "absolutely" portable code

From Kaz Kylheku <kaz@kylheku.com>
Newsgroups comp.lang.c
Subject Re: Writing "absolutely" portable code
Date 2012-01-18 00:40 +0000
Organization A noiseless patient Spider
Message-ID <20120117161245.963@kylheku.com> (permalink)
References (1 earlier) <lnk4504hip.fsf@nuthaus.mib.org> <9n386nF9sgU1@mid.uni-berlin.de> <jf4m48$7ig$1@dont-email.me> <jf4uu2$g2u$1@dont-email.me> <87haztzyze.fsf@blp.benpfaff.org>

Show all headers | View raw


On 2012-01-17, Ben Pfaff <blp@cs.stanford.edu> wrote:
> ec429 <ec429@cam.ac.uk> writes:
>
>> On 17/01/12 20:36, Nick Bowler wrote:
>>> On Tue, 10 Jan 2012 17:44:07 +0100, Dirk Zabel wrote:
>>>> So from this experiences, I would greatly prefer a manually written,
>>>> clean makefile together with some pre-written config.h where the
>>>> system-dependent definitions are visible.
>>>
>>> I cannot fathom why anyone would expect a from-scratch build system
>>> written by such developers to feature better support for cross
>>> compilation.
>> Perhaps because a build system that doesn't try to autoguess the
>> values of system-dependent things, doesn't break when the build
>> machine and target machine are different?
>> If you're cross-compiling, and the package uses autoconf, how's it
>> going to find out the values it normally gets by compiling and running
>> test programs?
>
> Autoconf doesn't normally try to run test programs.  Most of the
> time, it only tries to compile and link them.  In the cases where
> running is desirable, normally one makes the Autoconf tests take
> a conservative guess at the result.

The conservative guesses are often stupidly inappropriate.

A much better response would be to fail the configure with a big message
at the end like this:

  *** The program can't be configured because it is being cross-compiled,
  *** and so some of the tests which run test programs cannot be executed.
  *** Here are all the variables whose values you need to export to do
  *** the right thing (so you don't have to read the configure script):
  *** ac_cv_blah=yes   # this indicates the target has blah support
  *** ac_cv_blorch=yes # the target has blorch support

What happens instead is the program configures successfully anyway.  You have
to read the output of configure, spot the problems, gather them into a list,
and then dig through the configure script to find out what variables to
manipulate to get a proper build.

Another better response, rather than failing, would be to try to make better
use of available information.

For instance, suppose that the --target is specified as a tuple which encodes
not only the fact that we are compiling for MIPS or ARM, but also that the OS
is linux.  The config system has no excuse for not taking advantage of this
little fact that was given to it as input.  If you know that the OS is Linux,
then you know, for instance, that the target OS has POSIX job control, so you
don't have to bother testing for it, and you certainly don't need to assume
that it's not there.

Yet the job control test in GNU Bash's configure script defaults to "no"
if it is not able to run the configure test. Linux or not, it will build
a bash that has no Ctrl-Z, and no "jobs", "fg" or "bg".

A couple of years ago, Wind River was shipping a compiled bash with no job
control because of this issue.  When cross compiling bash, they just trusted
that configure did the job because it ran successfully and an executable popped
out make.

It's very hard to test for every single thing like this across an entire OS.
You never know where something is crippled because a cross-compiling test
was *silently* not run and a poor-quality default substituted in its place.

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-09 02:26 -0800
  Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-09 11:47 +0000
    Re: Writing "absolutely" portable code Jens Gustedt <jens.gustedt@loria.fr> - 2012-01-09 13:56 +0100
    Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-09 05:45 -0800
      Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-09 14:46 +0000
        Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-10 01:11 -0800
    Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-09 15:58 +0000
    Re: Writing "absolutely" portable code falk@rahul.net (Edward A. Falk) - 2012-01-09 18:41 +0000
  Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-09 12:23 +0000
    Re: Writing "absolutely" portable code Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-09 08:45 -0500
      Re: Writing "absolutely" portable code superpollo <superpollo@tznvy.pbz> - 2012-01-09 15:02 +0100
        Re: Writing "absolutely" portable code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-09 16:11 +0000
    Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-09 05:56 -0800
      Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-09 15:07 +0000
        Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-10 01:21 -0800
          Re: Writing "absolutely" portable code Stephen Sprunk <stephen@sprunk.org> - 2012-01-10 13:20 -0600
            Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-11 06:57 -0800
          Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-11 09:23 +0000
  Re: Writing "absolutely" portable code jacob navia <jacob@spamsink.net> - 2012-01-09 13:48 +0100
    Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-09 13:11 +0000
      Re: Writing "absolutely" portable code Nick Keighley <nick_keighley_nospam@hotmail.com> - 2012-01-09 05:27 -0800
        Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-09 13:41 +0000
          Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-09 06:09 -0800
      Re: Writing "absolutely" portable code jacob navia <jacob@spamsink.net> - 2012-01-09 14:35 +0100
        Re: Writing "absolutely" portable code Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-09 13:44 +0000
          Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-09 06:18 -0800
          Re: Writing "absolutely" portable code jacob navia <jacob@spamsink.net> - 2012-01-09 18:59 +0100
          Re: Writing "absolutely" portable code jacob navia <jacob@spamsink.net> - 2012-01-09 19:01 +0100
            Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-09 19:21 +0000
              Re: Writing "absolutely" portable code Richard <rgrdev_@gmail.com> - 2012-01-10 20:48 +0100
                Re: Writing "absolutely" portable code David Dyer-Bennet <dd-b@dd-b.net> - 2012-01-10 14:26 -0600
                Re: Writing "absolutely" portable code Richard <rgrdev_@gmail.com> - 2012-01-10 21:44 +0100
                Re: Writing "absolutely" portable code David Dyer-Bennet <dd-b@dd-b.net> - 2012-01-10 15:45 -0600
                Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-11 09:12 +0000
                Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-11 11:10 +0000
                Re: Writing "absolutely" portable code James Kuyper <jameskuyper@verizon.net> - 2012-01-11 11:52 -0500
                Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-11 17:01 +0000
                Re: Writing "absolutely" portable code James Kuyper <jameskuyper@verizon.net> - 2012-01-11 12:11 -0500
              Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-11 09:08 +0000
            Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-11 08:22 +0000
            Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-11 08:54 +0000
        Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-09 13:57 +0000
          Re: Writing "absolutely" portable code Seebs <usenet-nospam@seebs.net> - 2012-01-09 19:21 +0000
            Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-09 19:52 +0000
              Re: Writing "absolutely" portable code Seebs <usenet-nospam@seebs.net> - 2012-01-09 20:20 +0000
        Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-09 06:16 -0800
    Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-09 06:02 -0800
  Re: Writing "absolutely" portable code Keith Thompson <kst-u@mib.org> - 2012-01-09 14:50 -0800
    Re: Writing "absolutely" portable code Kaz Kylheku <kaz@kylheku.com> - 2012-01-09 23:20 +0000
      Re: Writing "absolutely" portable code Rui Maciel <rui.maciel@gmail.com> - 2012-01-10 00:23 +0000
    Re: Writing "absolutely" portable code Dirk Zabel <zabel@riccius-sohn.eu> - 2012-01-10 17:44 +0100
      Re: Writing "absolutely" portable code ArifulHossain tuhin <etothepowerpi@gmail.com> - 2012-01-11 07:13 -0800
      Re: Writing "absolutely" portable code Nick Bowler <nbowler@draconx.ca> - 2012-01-17 20:36 +0000
        Re: Writing "absolutely" portable code ec429 <ec429@cam.ac.uk> - 2012-01-17 23:06 +0000
          Re: Writing "absolutely" portable code blp@cs.stanford.edu (Ben Pfaff) - 2012-01-17 15:32 -0800
            Re: Writing "absolutely" portable code Kaz Kylheku <kaz@kylheku.com> - 2012-01-18 00:40 +0000
              Re: Writing "absolutely" portable code Seebs <usenet-nospam@seebs.net> - 2012-01-18 18:35 +0000
                Re: Writing "absolutely" portable code Kaz Kylheku <kaz@kylheku.com> - 2012-01-18 19:15 +0000
                Re: Writing "absolutely" portable code Seebs <usenet-nospam@seebs.net> - 2012-01-21 21:32 +0000
            Re: Writing "absolutely" portable code "io_x" <a@b.c.invalid> - 2012-01-18 07:26 +0100
              Re: Writing "absolutely" portable code "Joachim Schmitz" <nospam.jojo@schmitz-digital.de> - 2012-01-18 11:07 +0100
                Re: Writing "absolutely" portable code Seebs <usenet-nospam@seebs.net> - 2012-01-21 21:32 +0000
                Re: Writing "absolutely" portable code Ian Collins <ian-news@hotmail.com> - 2012-01-22 10:42 +1300
                Re: Writing "absolutely" portable code "io_x" <a@b.c.invalid> - 2012-01-22 18:53 +0100
                Re: Writing "absolutely" portable code "io_x" <a@b.c.invalid> - 2012-01-22 19:00 +0100
                Re: Writing "absolutely" portable code "io_x" <a@b.c.invalid> - 2012-01-23 19:28 +0100
              Re: Writing "absolutely" portable code Stephen Sprunk <stephen@sprunk.org> - 2012-01-18 08:44 -0600
              Re: Writing "absolutely" portable code James Dow Allen <jdallen2000@yahoo.com> - 2012-01-18 07:09 -0800
                Re: Writing "absolutely" portable code "io_x" <a@b.c.invalid> - 2012-01-18 17:44 +0100
        Re: Writing "absolutely" portable code Seebs <usenet-nospam@seebs.net> - 2012-01-18 07:58 +0000

csiph-web