perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

Fix two flaws in Configure

Open khwilliamson opened this issue 3 months ago • 7 comments

Configure conflated the file 'cppstdin' and the variable $cppstdin, failing to initialize the latter.

It also overrode the hints file wrapper for feeding stdin to the C preprocessor. It did this without asking, but ran a simple test, and if it passed, did the override. This behavior dates to the mid 1990s. The problem is that on z/OS the simple test passes, but not all inputs do.

Some system header files on z/OS have C trigraphs, which cause modern compilers to warn about them. The hints file wrapper, which dates from the late 1990's, did an "fgrep -v" to get rid of them, but it doesn't end up getting used. The simple test that Configure ends up of course would not think to try trigraphs. (There may be other issues as well, but this one really pops out.)

This commit initializes $cppstdin, and doesn't try to override a furnished cppstdin from the hints.

  • This set of changes does not require a perldelta entry.

khwilliamson avatar Sep 04 '25 03:09 khwilliamson

looks like some cleanup or filtering is missing:

# There are uncommitted changes in the working directory
# ?? cppstdin
# 

tonycoz avatar Sep 04 '25 04:09 tonycoz

It looks like this is a victim of bit rot. cppstdin is used as a variable in a few places to indicate what to eval to feed stdin to the C preprocessor. When set to point to a file that file contains the commands. In grepping through the source, this appears to be the only place where a file is used. The comments in hints/os390.sh say

We have our own cppstdin script. This is not a variable since Configure sees the presence of the script file. We put system header -D definitions in so that Configure can find the shmat() prototype in <sys/shm.h> and various other things. Unfortunately, cppflags occurs too late to be of value external to the script. This may need to be revisited

I don't understand what that all means.

Errno looks to see if it is an actual file.

sub default_cpp {
    unless (defined $cppstdin) {
	use File::Spec;
	$cppstdin = $Config{cppstdin};
	my $upup_cppstdin = File::Spec->catfile(File::Spec->updir,
						File::Spec->updir,
						"cppstdin");
	my $cppstdin_is_wrapper =
	    ($cppstdin eq 'cppstdin'
		and -f $upup_cppstdin
		    and -x $upup_cppstdin);
	$cppstdin = $upup_cppstdin if $cppstdin_is_wrapper;
    }
    return "$cppstdin $Config{cppflags} $Config{cppminus}";
}

So, this is supposed to be able to be a file, but all but this usage of it has been removed, and this one got broken without anyone noticing. I can try to make this into just a variable, I suppose.

@Tux, any ideas?

khwilliamson avatar Sep 04 '25 11:09 khwilliamson

When I try to build from this branch, ./Configure hangs indefinitely here:

Checking for GNU cc in disguise and/or its version number...
Now, how can we feed standard input to your C preprocessor...

jkeenan avatar Sep 06 '25 00:09 jkeenan

When I try to build from this branch, ./Configure hangs indefinitely here:

It's probably waiting for end of file (Ctrl-D)

tonycoz avatar Sep 08 '25 22:09 tonycoz

When I try to build from this branch, ./Configure hangs indefinitely here:

It's probably waiting for end of file (Ctrl-D)

Well, I've never seen this before in all the thousands of times I've run ./Configure.

jkeenan avatar Sep 09 '25 00:09 jkeenan

This is pretty complicated; I imagine it will have to wait until @Tux gets a chance to grok it and discuss it with me

khwilliamson avatar Sep 09 '25 00:09 khwilliamson

Well, I've never seen this before in all the thousands of times I've run Ctrl-D.

"Run Configure" I hope :)

But you did get a "waiting for input" hang in Configure once before.

tonycoz avatar Sep 09 '25 04:09 tonycoz