| Store | Cart

[perl #123006] Embedding perl with -DPERL_NO_SHORT_NAMES is not -Wall clean

From: Tony Cook via RT <perl...@perl.org>
Wed, 29 Oct 2014 18:13:42 -0700
On Sat Oct 18 16:19:44 2014, sprout wrote:
> PERL_NO_SHORT_NAMES is, unfortunately, unmaintained, and has been for> a long time (maybe even a decade or more?).  We have no infrastructure> for testing it.

That isn't too hard to test, since we already test embedding.  Patches attached.

> Nor do we have any convention for documenting which> items in perlapi.pod are macros (for which the Perl_ prefix would not> work), and this has changed back and forth for many functions/macros.

This is the main problem.  What should be available under PERL_NO_SHORT_NAMES?

Should PL_* variables be available?

> I wonder whether we should just remove it from perlembed.pod, or> altogether.  But there is certainly room for conflict with other C> headers.  So I don’t see any easy solution.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=123006

From 84f5da0cd316cbeeed8b3bc635ecce7cdca31a07 Mon Sep 17 00:00:00 2001
From: Tony Cook <t...@develop-help.com>
Date: Thu, 30 Oct 2014 11:55:52 +1100
Subject: Test::More ify lib/ExtUtils/t/Embed.t

---
 lib/ExtUtils/t/Embed.t |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/ExtUtils/t/Embed.t b/lib/ExtUtils/t/Embed.t
index 4e05cfe..72e0726 100644
--- a/lib/ExtUtils/t/Embed.t
+++ b/lib/ExtUtils/t/Embed.t
@@ -12,6 +12,7 @@ use Config;
 use ExtUtils::Embed;
 use File::Spec;
 use IPC::Cmd qw(can_run);
+use Test::More;
 
 my $cc = $Config{'cc'};
 if ( $Config{usecrosscompile} && !can_run($cc) ) {
@@ -23,7 +24,7 @@ print $fh <DATA>;
 close($fh);
 
 $| = 1;
-print "1..10\n";
+plan tests => 3;
 
 my $cl  = ($^O eq 'MSWin32' && $cc eq 'cl');
 my $skip_exe = $^O eq 'os2' && $Config{ldflags} =~ /(?<!\S)-Zexe\b/;
@@ -136,13 +137,18 @@ if ($^O eq 'VMS' && !$status) {
   print "# @cmd2\n";
   $status = system(join(' ',@cmd2));
 }
-print (($status? 'not ': '')."ok 1\n");
+is($status, 0, "build correctly");
 
 my $embed_test = File::Spec->catfile(File::Spec->curdir, $exe);
 $embed_test = "run/nodebug $exe" if $^O eq 'VMS';
 print "# embed_test = $embed_test\n";
-$status = system($embed_test);
-print (($status? 'not ':'')."ok 10 # system returned $status\n");
+...@out = `$embed_test`;
+chomp @out;
+is_deeply(\@out,
+	  [ map "ok $_", 2..9 ],
+	  "check test output");
+$status = $?;
+is($status, 0, "embedded code run correctly");
 unlink($exe,"embed_test.c",$obj);
 unlink("$exe.manifest") if $cl and $Config{'ccversion'} =~ /^(\d+)/ and $1 >= 14;
 unlink("$exe$Config{exe_ext}") if $skip_exe;
-- 
1.7.10.4


From 4037d43257122e5784acf54ddd834cdfe76e1e1b Mon Sep 17 00:00:00 2001
From: Tony Cook <t...@develop-help.com>
Date: Thu, 30 Oct 2014 12:07:41 +1100
Subject: roughly "fix" the build failures for PERL_NO_SHORT_NAMES builds

The AvFILL() definition uses mg_size(), a different solution would
be to change the AvFILL() definition to use Perl_mg_size().

The S__is_utf8_char_slow() change should be obvious.

All subject to change as we nail down what should be exposed under
PERL_NO_SHORT_NAMES.
---
 inline.h |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/inline.h b/inline.h
index 5256e8c..63f9fa3 100644
--- a/inline.h
+++ b/inline.h
@@ -14,6 +14,8 @@
 
 /* ------------------------------- av.h ------------------------------- */
 
+#ifndef PERL_NO_SHORT_NAMES
+
 PERL_STATIC_INLINE SSize_t
 S_av_top_index(pTHX_ AV *av)
 {
@@ -23,6 +25,8 @@ S_av_top_index(pTHX_ AV *av)
     return AvFILL(av);
 }
 
+#endif
+
 /* ------------------------------- cv.h ------------------------------- */
 
 PERL_STATIC_INLINE GV *
@@ -239,7 +243,7 @@ S__is_utf8_char_slow(const U8 *s, const U8 *e)
     PERL_ARGS_ASSERT__IS_UTF8_CHAR_SLOW;
 
     assert(e >= s);
-    utf8n_to_uvchr(s, e - s, &actual_len, UTF8_CHECK_ONLY);
+    Perl_utf8n_to_uvchr(aTHX_ s, e - s, &actual_len, UTF8_CHECK_ONLY);
 
     return (actual_len == (STRLEN) -1) ? 0 : actual_len;
 }
-- 
1.7.10.4


From 55fb4a018a8dea027c6ffcdf24489d995ed4531a Mon Sep 17 00:00:00 2001
From: Tony Cook <t...@develop-help.com>
Date: Thu, 30 Oct 2014 12:08:09 +1100
Subject: test that embedding works with PERL_NO_SHORT_NAMES defined

---
 lib/ExtUtils/t/Embed.t |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lib/ExtUtils/t/Embed.t b/lib/ExtUtils/t/Embed.t
index 72e0726..f01a14c 100644
--- a/lib/ExtUtils/t/Embed.t
+++ b/lib/ExtUtils/t/Embed.t
@@ -24,8 +24,9 @@ print $fh <DATA>;
 close($fh);
 
 $| = 1;
-plan tests => 3;
+plan tests => 6;
 
+for my $short_names (0, 1) {
 my $cl  = ($^O eq 'MSWin32' && $cc eq 'cl');
 my $skip_exe = $^O eq 'os2' && $Config{ldflags} =~ /(?<!\S)-Zexe\b/;
 my $exe = 'embed_test';
@@ -53,6 +54,7 @@ if ($^O eq 'VMS') {
     }
     $crazy =~ s#/Obj[^=/]*=[\w\$\_\-\.\[\]\:]+##i;
     push(@cmd,"/Include=(".join(',',@incs).")");
+    push(@cmd, "/Define=PERL_NO_SHORT_NAMES") if $short_names;
     push(@cmd,$crazy);
     push(@cmd,"embed_test.c");
 
@@ -74,6 +76,7 @@ if ($^O eq 'VMS') {
    }
 
    push(@cmd,"-I$inc",ccflags(),'embed_test.c');
+   push(@cmd, "-DPERL_NO_SHORT_NAMES") if $short_names;
    if ($^O eq 'MSWin32') {
     $inc = File::Spec->catdir($inc,'win32');
     push(@cmd,"-I$inc");
@@ -149,12 +152,15 @@ is_deeply(\@out,
 	  "check test output");
 $status = $?;
 is($status, 0, "embedded code run correctly");
-unlink($exe,"embed_test.c",$obj);
+unlink($exe,$obj);
 unlink("$exe.manifest") if $cl and $Config{'ccversion'} =~ /^(\d+)/ and $1 >= 14;
 unlink("$exe$Config{exe_ext}") if $skip_exe;
 unlink("embed_test.map","embed_test.lis") if $^O eq 'VMS';
 unlink(glob("./*.dll")) if $^O eq 'cygwin';
 unlink($testlib)	       if $libperl_copied;
+}
+
+unlink("embed_test.c");
 
 # gcc -g -I.. -L../ -o perl_test perl_test.c -lperl `../perl -I../lib -MExtUtils::Embed -I../ -e ccflags -e ldopts`
 __END__
-- 
1.7.10.4


Recent Messages in this Thread
(via RT) Oct 18, 2014 09:46 pm
James E Keenan via RT Oct 18, 2014 10:13 pm
Father Chrysostomos via RT Oct 18, 2014 11:19 pm
Leon Timmermans Oct 21, 2014 10:56 pm
Tony Cook via RT Oct 30, 2014 01:13 am
Andrew Fresh Oct 18, 2014 10:19 pm
Messages in this thread