Discussion:
bug#12741: any cross-compile fails due to new make-prime-list
(too old to reply)
Jim Meyering
2012-10-26 15:37:13 UTC
Permalink
As reported privately by Yegor Yefremov:

coreutils-8.20 has interesting issue. Have you tried to cross
compile it for ARM? I get following error:

GEN src/primes.h
/bin/sh: src/make-prime-list: cannot execute binary file
make[1]: * [src/primes.h] Error 126

because make-prime-list is also cross compiled. Any idea how to fix this?

Thanks for the bug report. (forwarding it to the bug-coreutils list)
Yes, that is a problem when cross-compiling to any target.

I would like to generate that table with a portable awk script (maybe
even Perl). If someone can provide such a script, I would be happy
to dump the C program. That would solve the problem.

You can work around it by touching the executable, creating the generated
file on another system and copying it to your build directory.
Paul Eggert
2012-10-26 17:07:18 UTC
Permalink
Post by Jim Meyering
I would like to generate that table with a portable awk script (maybe
even Perl). If someone can provide such a script, I would be happy
to dump the C program. That would solve the problem.
It'd be a pain to do it in portable awk, as it requires
arithmetic modulo (UINTMAX_MAX + 1), which Awk is not
likely to support directly.

Since there are only two or three plausible values of UINTMAX_MAX
these days, one possibility is to precompute primes.h for these
two or three values, and ship the precomputed primes.h in the
tarball, and to use the precomputed primes.h on hosts with typical
UINTMAX_MAX values. People who are on a weird platform where
UINTMAX_MAX is an unusual value wouldn't be able to cross-compile,
but that's unlikely to ever happen and even if it does, we simply
add the unusual case to the precomputed primes.h.
Jim Meyering
2012-10-26 17:27:42 UTC
Permalink
Post by Paul Eggert
Post by Jim Meyering
I would like to generate that table with a portable awk script (maybe
even Perl). If someone can provide such a script, I would be happy
to dump the C program. That would solve the problem.
It'd be a pain to do it in portable awk, as it requires
arithmetic modulo (UINTMAX_MAX + 1), which Awk is not
likely to support directly.
Since there are only two or three plausible values of UINTMAX_MAX
these days, one possibility is to precompute primes.h for these
two or three values, and ship the precomputed primes.h in the
tarball, and to use the precomputed primes.h on hosts with typical
UINTMAX_MAX values. People who are on a weird platform where
UINTMAX_MAX is an unusual value wouldn't be able to cross-compile,
but that's unlikely to ever happen and even if it does, we simply
add the unusual case to the precomputed primes.h.
That would be fine with me.
We were precomputing the "wheel.h" table of primes before, too.

If we go the route of distributing the generated file,
then we might as well resort to using Perl and say, -Mbigint,
to do generate all variants.
Assaf Gordon
2018-11-06 18:10:17 UTC
Permalink
tags 12741 fixed
close 12741
stop

(triaging old bugs)
Post by Jim Meyering
That would be fine with me.
We were precomputing the "wheel.h" table of primes before, too.
If we go the route of distributing the generated file,
then we might as well resort to using Perl and say, -Mbigint,
to do generate all variants.
Starting with version 8.21, "prime.h" is pre-built and distributed.

Committed here:
https://git.savannah.gnu.org/cgit/coreutils.git/commit/?id=f16e251dae43117c2cd19359c26ce7b5e05165b6

As such, closing this bug.

-assaf

Continue reading on narkive:
Loading...