1445 Commits

Author SHA1 Message Date
Scott Baker
8d1c2aec21 Use getentropy() for seeding PRNG in Perl_seed()
On libc (*nix) systems we call `getentropy()` to get the seed needed to
start the PRNG. If that call fails, we fall back to reading the
filesystem via `/dev/urandom`. If that fails we fall back to hashing
some state variables instead.

This should be faster, less risky, and generally better than trying to
read from `/dev/urandom`

Foo
2026-01-23 11:03:16 -07:00
TAKAI Kousuke
e6d5a81fed Configure: check usability of <stdckdint.h>, not only its existence
Some FreeBSD systems have <stdckdint.h>, but it cannot be compiled
with C++ compilers.  Configure now checks whether `ckd_*` functions
can be compiled, and leave I_STDCKDINT undefined if the compilation
failed.

Will fix GH #23725 (d51aa1a build-time failure with clang++ and g++).
2025-09-21 06:51:10 -06:00
TAKAI Kousuke
d51aa1a511 Introduce I_STDCKDINT config macro
This macro is defined in config.h if <stdckdint.h> is available,
and used in previously commited code
(0f2b1e648156555a96ed54170e1b385a60010910, GH #23503).
2025-09-16 13:55:31 -06:00
H.Merijn Brand
6fbe2c7e05 pack "s>" was introduced in perl-5.10 2025-06-03 09:29:14 +02:00
Leon Timmermans
1f9097b342 Detect presence of fdopendir in Configure 2025-05-28 02:30:13 +02:00
Karl Williamson
9e9b2f9f44 Configure: make sure pointers fit in IVs
See #18995

This commit just adds a simple test that IV is large enough to hold a
pointer; something we claim is true, but didn't actually guarantee.
2025-05-13 15:02:42 -06:00
Karl Williamson
b69c87a28e Configure: Avoid printf format type mismatch
Sometimes the value being printed is a long; sometimes not.  In order to
get it to always work properly, cast to a long and use %ld
2024-12-04 05:52:14 -07:00
Karl Williamson
c9a9e95023 Configure: Fix compilation error on some systems
See https://github.com/Perl/perl5/issues/22793

This typo in a printf format causes some C compilations to fail; others
to just warn.  However stderr is redirected to /dev/null, so we weren't
aware of this issue.

When it fails, other issues cause perl to not be usable on the system.
2024-12-04 05:51:45 -07:00
H.Merijn Brand
404e97f797 /\=/ does not require \ even in older awk 2024-04-25 12:26:50 +02:00
Tony Cook
cab7c32968 Configure: eliminate some left over debug output
The LC_ALL syntax detection wrote some of what it detected to
the console with no labels.

On Linux this was:

  "=;"

for both lines, but I've seen more complex output on other systems.
2024-04-12 14:31:12 +10:00
Karl Williamson
08cb8dc811 Configure: Handle case of no localeconv() found
If not found, there certainly won't be a subset of its returns
2024-01-15 12:16:51 -07:00
H.Merijn Brand
ca4e10252d Unmatched {} in C file generated by Configure issue#21730 m-hilgendorf 2024-01-15 15:38:51 +01:00
Karl Williamson
80be29bd8f Configure: Fix swapped responses for SETLOCALE_ACCEPTS_ANY_LOCALE_NAME
Answering y gave the opposite of what was intended; and vice-versa
2023-12-12 09:39:32 -07:00
Tony Cook
0944cd7375 Configure: ensure LC_ALL test code doesn't have escapes escaped
Some \" was being converted to " with ksh on AIX, causing the
program to fail to build and failing the entire build.

Example report: https://perl5.test-smoke.org/report/5039146

Errors:
"config.h", line 3640.3: 1506-218 (E) Unknown preprocessing directive #PERL_LC_ALL_USES_NAME_VALUE_PAIRS.
"config.h", line 3641.4: 1506-218 (E) Unknown preprocessing directive #PERL_LC_ALL_SEPARATOR.
"config.h", line 3642.4: 1506-218 (E) Unknown preprocessing directive #PERL_LC_ALL_CATEGORY_POSITIONS_INIT.
"locale.c", line 6865.43: 1506-168 (S) Initializer must be enclosed in braces.
"locale.c", line 6866.31: 1506-043 (S) The operand of the sizeof operator is not valid.
"locale.c", line 6866.9: 1506-044 (S) Expression must be a non-negative integer constant.
"locale.c", line 6870.18: 1506-043 (S) The operand of the sizeof operator is not valid.
2023-09-05 15:47:48 +10:00
H.Merijn Brand
6a09651902 Merge Configure diverges + missing parts 2023-08-14 10:56:10 +02:00
Karl Williamson
c3c6153b29 Fix up regenerated Configure
This commit fixes some bugs introduced in
c4db344da5d363eb1cbbcc5aefa32aed0c409f6e via rebasing issues.
2023-08-07 20:29:33 -06:00
Karl Williamson
c4db344da5 Regenerate Configure from latest metaconfig
This includes the LC_ALL notation unit, not yet merged in metaconfig.

It turns out that in order to get quite a few elements from being
dropped, I had to add them to metaconfig.h
2023-08-02 09:02:24 -06:00
H.Merijn Brand
a467770927 Add distribution-friendly make message (PR#21207)
by Elvin Aslanov (rwp0)

Straight to the point as "Public domain implementation" wasn't very helpful.

Came across this message building Perl on a freshly installed Ubuntu Linux doing:

 git clone https://github.com/Perl/perl5
 sh Configure -des -Dusedevel
2023-07-10 11:02:54 +02:00
TAKAI Kousuke
2ed1779635 Configure: prefer %ll over %L for formatting long long ints
Configure used to try %L, %q, and then %ll in this order to find the
modifier for formatting 64-bit integers on 32-bit machines, but %L for
integer conversions seems to be a non-standard GNU extension.
Now it will try %ll before %q, %L to prioritize %ll which is
standardized by C99.
2023-07-02 17:54:49 -06:00
vsfos
2979f5f343 fix typo in Configure, ">& 4" to ">&4" 2023-05-22 11:51:42 +02:00
Yves Orton
10d2893869 Replace "define\t" with "define " in Configure/metaconfig related files
This is broken out so it is easier for Tux to find and merge with
metaconfig.

View this patch with -w and you will see "no changes" except for
config_h.SH and Porting/config_h.pl both which needed to be changed to
ensure that they produce output that doesn't replicate the problem.
2023-04-29 09:09:53 +02:00
H.Merijn Brand
615e365887 Add sys/syscall.h probe 2023-04-28 17:49:33 +02:00
H.Merijn Brand
934479e4e0 ask the compiler to find libquadmath
Currently this requires special handling on Linux and is broken
on Cygwin, since the compiler internal library directories
aren't in the normal search path.

Rather than searching ourselves, let the compiler do it, and check
it's vaguely functional.
2023-04-28 09:09:55 +02:00
H.Merijn Brand
d224e8addb Manually re-order to simplify oncoming quadmath change 2023-04-27 14:01:53 +02:00
H.Merijn Brand
e6cab701ba Regen Configure after backports 2023-04-27 11:52:46 +02:00
Tony Cook
d8a109ccd8 Configure: don't probe for the malloc()/free() return type
We require a C99 compiler, or in the case that led to this commit, a
C++ compiler, and for those the malloc() and free() return types are
well defined.

This probe broke on Solaris when building with g++.

Unlike glibc, the libc headers on Solaris, when building using a C++
compiler, define the stdlib.h functions within the std:: namespace,
then imports those names into the top level namespace with 'using
std::malloc'.

This conflicts with the declarations used in the probe, causing the
probe to fail to build, despite malloc() actually returning a void *.

Since these two functions have well defined return types according to
the standard, assume their return values match.

Configure can still be invoked with different definitions for
malloctype and freetype, or hints can override them, so someone on a
non-standard system can at least get past this if they really need to
(such a system will likely not build perl anyway.)
2023-02-14 09:23:55 +11:00
Kurt Fitzner
85d2c8e80f Configure - fix handling of quoted gcc output
This patch was submitted in GH issue #20606. When gcc output contains
quoted elements we fail to handle it properly. This tweaks the sed
command to do so.

Fixes #20606.
2023-01-31 00:52:23 +08:00
Florian Weimer
fc35cee89c Configure: Add various C99 compatibility improvements
Two C99 compatibility issues are fixed by these changes: Return
types are made explicit where they previously defaulted to int,
and all called functions are now declared explicitly (either by
including additional headers, or by adding prototypes manually).

This avoids implict ints and implicit function declarations,
both legacy C language features removed in the 1999 revision
of the language.

Verified with an instrumented GCC compiler on GNU/Linux.
2023-01-17 13:44:03 -07:00
Peter Levine
e1ca9a418f Add parameter types to declarations for clang-16
ANSI C style function declarations without parameter types are errors with clang-16.
2023-01-17 11:05:44 -07:00
TAKAI Kousuke
a503b7406f Figure out I32df, U32uf, etc. in Configure rather than in perl.h
These macros were defined in perl.h using preprocessor conditionals,
but determining wheter I32 is "int" or "long" is pretty hard with
preprocessor, when INTSIZE == LONGSIZE.  The Configure script
should know exact underlying type of I32, so it should be able to
determine whether %d or %ld shall be used to format I32 value
more robustly.

Various pre-configured files, such as uconfig.h, are updated to
align with this.
2022-11-14 15:40:56 +11:00
danielnachun
7e19816aa8 Configure: remove nsl from libswanted 2022-09-03 18:14:47 +02:00
Nicholas Clark
46bfb3c49f Configure should avoid looping infinitely repeating the same question
Configure's helper function ./myread is intended to loop until it gets an
acceptable answer. For a couple of cases, an empty string is not acceptable
(eg 'Where is your C library?', if all automated attempts at answering this
have failed). In these cases, if Configure's standard input is /dev/null (or
closed), the shell read returns an empty string, and ./myread repeats the
question.

Before this commit, it would loop infinitely (generating continuous terminal
output). With this commit, we add a retry counter - if it asks the same
question to many times, it aborts Configure. This means that unattended
./Configure runs should now always terminate, as termination with an error
is better than spinning forever.
2022-08-02 18:27:22 +02:00
Tony Cook
be2d063f33 properly populate osvers on Dragonfly BSD when the hostname isn't set
A default installation of DragonflyBSD doesn't necessarily set the
hostname, resulting in a `uname -a` like:

  DragonFly  6.2-RELEASE DragonFly v6.2.2-RELEASE ...

which resulted in osvers being set to "dragonfly", which isn't
especially useful.

So check that $3 is numeric in some sense before using it, falling
back to $2 if it isn't.  This should only happen when the hostname
isn't set.
2022-07-20 14:59:40 -06:00
TAKAI Kousuke
e005a3c01b Configure: Add missing #include <inttypes.h> to test programs
With -Duse64bitint on 32-bit machines, UV might be configured
to `uint64_t`.  But some Configure tests used $uvtype without including
<inttypes.h>, which may cause compilation error of those tests on
sucn configurations, and eventually make perl not built correctly.
2022-07-20 14:55:35 -06:00
TAKAI Kousuke
fc3ce1a8e4 Configure: Fix typos for C99 macro name PRIX64
There are no macros named PRIXU64.  This line seems to date back to
commit 6b356c8efb963846940ef92952cf77e5b86bd65e which renamed shell
variable names to work well with case-insensitive systems,
but could have overdone a bit.
2022-07-20 14:55:35 -06:00
Tomasz Konojacki
0351a629e7 hide private functions with __attribute__((visibility("hidden")))
This allows us to enforce API boundaries and potentially enables
compiler optimisations.

We've been always hiding non-public symbols on Windows. This commit
brings that to the other platforms.
2022-06-18 08:51:14 +02:00
Leon Timmermans
f15e478c60 Update libsearch paths for cygwin 2022-06-14 19:41:17 +02:00
Tomasz Konojacki
2e2065489c probe for setenv in Configure 2022-05-29 00:54:10 +02:00
Paul "LeoNerd" Evans
28003a9581 Revert "Add Configure question for taint support"
This reverts commit 39f8eb4a21670e6b973dcfc86d0b1339064f5642.

This is because of a variety of issues discussed #19657 and at the PSC
meeting 064 2022-04-22

https://www.nntp.perl.org/group/perl.perl5.porters/2022/04/msg263670.html
2022-05-19 17:53:44 +01:00
Neil Bowers
39f8eb4a21 Add Configure question for taint support
This adds a Configure question for whether you want taint support.
It defaults to "yes", so that ./Configure -des will build a perl
which supports taint in the usual way.
If you say "no", then perl is compiled with -DSILENT_NO_TAINT_SUPPORT
so that taint features silently do nothing.

I've submitted a separate pull request on perl/metaconfig,
which adds the underlying metaconfig unit for this question,
which was used to build this Configure script.
2022-04-20 11:38:21 +01:00
TAKAI Kousuke
3aea88f20c Fixed possible syntax error in Configure's test program for Inf/NaN bytes.
"try.c" for (double|longdbl)(inf|nan)bytes seems to lack some
preprocessor directives (probably accidentaly removed) and
caused syntax error if HAS_LONG_DOUBLE is not defined.
2022-03-05 19:13:49 -07:00
H.Merijn Brand
30194bf8f4 Regen Configure and friends after backports 2021-10-29 19:42:38 +02:00
James E Keenan
786c02c930 Send bugs to GitHub
Do not advise sending mail to 'perlbug@perl.org', as that now simply
triggers a response redirecting sender to GitHub.
2021-10-13 21:55:07 +00:00
Nicholas Clark
d34aca5e9e Test declarations after statement in Configure's C99 probe code
Also ensure that the relevant failure error message is output even with
Configure's -s flag, as we shouldn't stay silent for a message that causes
Configure default to aborting.

With these changes, Configure will fail the C99 probe test if passed
-Accflags="-Werror=declaration-after-statement" or
-Accflags="-Werror=long-long"
2021-10-13 08:09:15 +02:00
Nicholas Clark
0c7be12024 Teach Configure and cflags.SH about C99
Probe to see whether we need -std=gnu99 or -std=c99 to get C99 code to
compile. In cflags.SH, remove code that added gcc warning flags that were
compatible with C89 but are not compatible with C99.
2021-10-13 08:09:15 +02:00
Nicholas Clark
65f7068160 A Configure test for C11 thread local storage specificer, _Thread_local
We also provbe for gcc's earlier syntax, __thread.
2021-09-07 15:46:16 +10:00
Tony Cook
9b5699737a detect struct stat.st_dev's size and signedness, and return it safely
On FreeBSD dev_t (and hence the st_dev member of struct stat) is an
unsigned 64-bit integer, and the previous simple PUSHi() corrupted
that.

A previous version of this reflected the st_ino code and implemented
our own number to string conversion, but a system with such a large
st_dev should be assumed to have inttypes.h, and an intmax_t which is
no smaller than st_dev.

The st_ino code could probably be changed similarly, but 64-bit inode
numbers are not a new thing, so it may be riskier.
2021-09-01 10:59:44 +10:00
H.Merijn Brand
f1258252af Regen Configure and Glossary after backport of xlocale.h addition 2021-08-11 13:34:21 +02:00
Tony Cook
68f1b6d700 only #include <xlocale.h> when it is actually needed
This header was originally only needed for builds on darwin and
FreeBSD, but was being included whenever it was detected.

This has caused problems when what was an internal header was
removed (from glibc) and in general wasn't needed anyway.

On FreeBSD only localeconv_l() requires xlocale.h, so we test
specifically for that.
2021-08-11 14:40:22 +10:00
H.Merijn Brand
78f044cf3c Disambiguate what user sees in interactive Configure
User should expect to see configuration questions spelled 'UTF-8', not
'UTF8' (even if we store information internally or in config.sh without
the hyphen).

Correct user prompts accordingly.

For: #18844

https://github.com/Perl/perl5/pull/18870 by @jkeenan
2021-06-16 08:30:15 +02:00