Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PATCH] Finish mathomizing Perl_instr #15265

Closed
p5pRT opened this issue Apr 7, 2016 · 9 comments
Closed

[PATCH] Finish mathomizing Perl_instr #15265

p5pRT opened this issue Apr 7, 2016 · 9 comments
Labels

Comments

@p5pRT
Copy link

p5pRT commented Apr 7, 2016

Migrated from rt.perl.org#127852 (status was 'resolved')

Searchable as RT127852$

@p5pRT
Copy link
Author

p5pRT commented Apr 7, 2016

From @craigberry

Sending to the list because of code freeze, but I think it should be a 5.24.0 blocker since it fixes a new problem we created within the last month. Patch inline and attached.

From 0ecbc6fd5c28fca6e5585e13fc2a9a4cfd56ecd2 Mon Sep 17 00​:00​:00 2001
From​: "Craig A. Berry" <craigberry@​mac.com>
Date​: Wed, 6 Apr 2016 20​:59​:12 -0500
Subject​: [PATCH] Finish mathomizing Perl_instr.

fea1d2d turned instr into a macro. It also left the
actual function in util.c while commenting out the prototype
in proto.h (via the m flag in embed.fnc).

A function compiled without a prototype under C++ does not get
declared with extern "C" and thus gets mangled, which breaks the
build with a strict linker (VMS, possibly AIX) because the
expected symbol name is no longer produced. Without a strict
linker, it just breaks the binary compatibility that was presumably
the nominal reason for leaving the function around in the first
place.

So move the function into mathoms.c and put its prototype in the
extern "C"-guarded section at the top of the same file.

We also have to fake the PERL_ARGS_ASSERT_INSTR macro since its
original declaration in proto.h is commented out but the porting
test t/porting/args_assert.t will take revenge if it doesn't
find the macro being used somewhere.


mathoms.c | 20 ++++++++++++++++++++
util.c | 12 ------------
2 files changed, 20 insertions(+), 12 deletions(-)

Inline Patch
diff --git a/mathoms.c b/mathoms.c
index 3187782..d530cc0 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -107,6 +107,9 @@ PERL_CALLCONV UV Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
 PERL_CALLCONV UV Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
 PERL_CALLCONV UV Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
 PERL_CALLCONV SV *Perl_sv_mortalcopy(pTHX_ SV *const oldstr);
+PERL_CALLCONV char*	Perl_instr(const char* big, const char* little)
+			__attribute__warn_unused_result__
+			__attribute__pure__;

 /* ref() is now a macro using Perl_doref;
  * this version provided for binary compatibility only.
@@ -1808,6 +1811,23 @@ Perl_pad_compname_type(pTHX_ const PADOFFSET po)
     return PAD_COMPNAME_TYPE(po);
 }

+/* now a macro */
+/* return ptr to little string in big string, NULL if not found */
+/* This routine was donated by Corey Satten. */
+
+char *
+Perl_instr(const char *big, const char *little)
+{
+    /* Porting tests require this macro to be used even though it doesn't exist
+     * (except for the commented-out version in proto.h).  So provide a commented-out
+     * "use" of the prototype and supply a real version of what it expanded to.
+    PERL_ARGS_ASSERT_INSTR;
+    */
+    assert(big);
+    assert(little);
+
+    return strstr((char*)big, (char*)little);
+}

 END_EXTERN_C

diff --git a/util.c b/util.c
index 89c44e7..447a19f 100644
--- a/util.c
+++ b/util.c
@@ -551,18 +551,6 @@ Perl_delimcpy(char *to, const char *toend, const char *from, const char *fromend
     return (char *)from;
 }

-/* return ptr to little string in big string, NULL if not found */
-/* This routine was donated by Corey Satten. */
-
-char *
-Perl_instr(const char *big, const char *little)
-{
-
-    PERL_ARGS_ASSERT_INSTR;
-
-    return strstr((char*)big, (char*)little);
-}
-
 /*
 =head1 Miscellaneous Functions

— 2\.2\.1

$ perl -"V"
Summary of my perl5 (revision 5 version 23 subversion 10) configuration​:
  Snapshot of​: c349b9a
  Platform​:
  osname=VMS, osvers=V8.4, archname=VMS_IA64
  uname='VMS alma V8.4 HP rx2600 (1.50GHz/6.0MB)'
  config_args='-"Dusedevel" -"DDEBUGGING" -"Dusevmsdebug" -"Dusecxx" -"Duser_c_flags=/WARN=INFORMATIONAL=NOCTOBUTCONREFM" -"des"'
  hint=none, useposix=false, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=undef, bincompat5005=undef
  Compiler​:
  cc='CXX', ccflags ='/Include=[]/Standard=ANSI/Prefix=All/Obj=.obj /NOANSI_ALIAS/float=ieee/ieee=denorm/NAMES=(SHORTENED)/WARN=INFORMATIONAL=NOCTOBUTCONREFM/Define=_USE_STD_STAT=1',
  optimize='/List/Debug/NoOpt',
  cppflags='undef'
  ccversion='70490005', gccversion='', gccosandvers='undef'
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234, doublekind=3
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=1
  ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='Link/nodebug', ldflags ='/Debug/Trace/Map'
  libpth=/sys$share /sys$library
  libs=
  perllibs=
  libc=(DECCRTL), so=exe, useshrplib=true, libperl=undef
  gnulibc_version='undef'
  Dynamic Linking​:
  dlsrc=dl_vms.xs, dlext=exe, d_dlsymun=undef, ccdlflags=''
  cccdlflags='', lddlflags='/Share'

Characteristics of this PERLSHR image​:
  Compile-time options​: DEBUGGING HAS_TIMES HAVE_INTERP_INTERN PERLIO_LAYERS
  PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV
  PERL_EXTERNAL_GLOB PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
  PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PERL_USE_DEVEL
  USE_IEEE USE_LARGE_FILES USE_LOCALE
  USE_LOCALE_COLLATE USE_LOCALE_CTYPE
  USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO
  USE_PERL_ATOF VMS_DO_SOCKETS
  VMS_SHORTEN_LONG_SYMBOLS
  Built under VMS
  Compiled at Apr 6 2016 23​:54​:00
  %ENV​:
  PERLSHR="perl_root​:[000000]perlshr.exe"
  PERL_ROOT="DSA0​:[craig.blead.]"
  @​INC​:
  /perl_root/lib/site_perl/VMS_IA64
  /perl_root/lib/site_perl
  /perl_root/lib/VMS_IA64/5_23_10
  /perl_root/lib
  .

@p5pRT
Copy link
Author

p5pRT commented Apr 7, 2016

From @craigberry

0001-Finish-mathomizing-Perl_instr.patch
From 0ecbc6fd5c28fca6e5585e13fc2a9a4cfd56ecd2 Mon Sep 17 00:00:00 2001
From: "Craig A. Berry" <craigberry@mac.com>
Date: Wed, 6 Apr 2016 20:59:12 -0500
Subject: [PATCH] Finish mathomizing Perl_instr.

fea1d2dd5d210564d4 turned instr into a macro.  It also left the
actual function in util.c while commenting out the prototype
in proto.h (via the m flag in embed.fnc).

A function compiled without a prototype under C++ does not get
declared with extern "C" and thus gets mangled, which breaks the
build with a strict linker (VMS, possibly AIX) because the
expected symbol name is no longer produced.  Without a strict
linker, it just breaks the binary compatibility that was presumably
the nominal reason for leaving the function around in the first
place.

So move the function into mathoms.c and put its prototype in the
extern "C"-guarded section at the top of the same file.

We also have to fake the PERL_ARGS_ASSERT_INSTR macro since its
original declaration in proto.h is commented out but the porting
test t/porting/args_assert.t will take revenge if it doesn't
find the macro being used somewhere.
---
 mathoms.c | 20 ++++++++++++++++++++
 util.c    | 12 ------------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/mathoms.c b/mathoms.c
index 3187782..d530cc0 100644
--- a/mathoms.c
+++ b/mathoms.c
@@ -107,6 +107,9 @@ PERL_CALLCONV UV Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
 PERL_CALLCONV UV Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
 PERL_CALLCONV UV Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
 PERL_CALLCONV SV *Perl_sv_mortalcopy(pTHX_ SV *const oldstr);
+PERL_CALLCONV char*	Perl_instr(const char* big, const char* little)
+			__attribute__warn_unused_result__
+			__attribute__pure__;
 
 /* ref() is now a macro using Perl_doref;
  * this version provided for binary compatibility only.
@@ -1808,6 +1811,23 @@ Perl_pad_compname_type(pTHX_ const PADOFFSET po)
     return PAD_COMPNAME_TYPE(po);
 }
 
+/* now a macro */
+/* return ptr to little string in big string, NULL if not found */
+/* This routine was donated by Corey Satten. */
+
+char *
+Perl_instr(const char *big, const char *little)
+{
+    /* Porting tests require this macro to be used even though it doesn't exist
+     * (except for the commented-out version in proto.h).  So provide a commented-out
+     * "use" of the prototype and supply a real version of what it expanded to.
+    PERL_ARGS_ASSERT_INSTR;
+    */
+    assert(big);
+    assert(little);
+
+    return strstr((char*)big, (char*)little);
+}
 
 END_EXTERN_C
 
diff --git a/util.c b/util.c
index 89c44e7..447a19f 100644
--- a/util.c
+++ b/util.c
@@ -551,18 +551,6 @@ Perl_delimcpy(char *to, const char *toend, const char *from, const char *fromend
     return (char *)from;
 }
 
-/* return ptr to little string in big string, NULL if not found */
-/* This routine was donated by Corey Satten. */
-
-char *
-Perl_instr(const char *big, const char *little)
-{
-
-    PERL_ARGS_ASSERT_INSTR;
-
-    return strstr((char*)big, (char*)little);
-}
-
 /*
 =head1 Miscellaneous Functions
 
-- 
2.2.1

@p5pRT
Copy link
Author

p5pRT commented Apr 7, 2016

From @khwilliamson

On 04/07/2016 06​:08 AM, Craig A. Berry (via RT) wrote​:

# New Ticket Created by Craig A. Berry
# Please include the string​: [perl #127852]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=127852 >

Sending to the list because of code freeze, but I think it should be a 5.24.0 blocker since it fixes a new problem we created within the last month. Patch inline and attached.

Maybe we should just revert that for 5.24

From 0ecbc6fd5c28fca6e5585e13fc2a9a4cfd56ecd2 Mon Sep 17 00​:00​:00 2001
From​: "Craig A. Berry" <craigberry@​mac.com>
Date​: Wed, 6 Apr 2016 20​:59​:12 -0500
Subject​: [PATCH] Finish mathomizing Perl_instr.

fea1d2d turned instr into a macro. It also left the
actual function in util.c while commenting out the prototype
in proto.h (via the m flag in embed.fnc).

A function compiled without a prototype under C++ does not get
declared with extern "C" and thus gets mangled, which breaks the
build with a strict linker (VMS, possibly AIX) because the
expected symbol name is no longer produced. Without a strict
linker, it just breaks the binary compatibility that was presumably
the nominal reason for leaving the function around in the first
place.

So move the function into mathoms.c and put its prototype in the
extern "C"-guarded section at the top of the same file.

We also have to fake the PERL_ARGS_ASSERT_INSTR macro since its
original declaration in proto.h is commented out but the porting
test t/porting/args_assert.t will take revenge if it doesn't
find the macro being used somewhere.
---
mathoms.c | 20 ++++++++++++++++++++
util.c | 12 ------------
2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/mathoms.c b/mathoms.c
index 3187782..d530cc0 100644
--- a/mathoms.c
+++ b/mathoms.c
@​@​ -107,6 +107,9 @​@​ PERL_CALLCONV UV Perl_to_utf8_title(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_utf8_upper(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
PERL_CALLCONV UV Perl_to_utf8_fold(pTHX_ const U8 *p, U8* ustrp, STRLEN *lenp);
PERL_CALLCONV SV *Perl_sv_mortalcopy(pTHX_ SV *const oldstr);
+PERL_CALLCONV char* Perl_instr(const char* big, const char* little)
+ __attribute__warn_unused_result__
+ __attribute__pure__;

/* ref() is now a macro using Perl_doref;
* this version provided for binary compatibility only.
@​@​ -1808,6 +1811,23 @​@​ Perl_pad_compname_type(pTHX_ const PADOFFSET po)
return PAD_COMPNAME_TYPE(po);
}

+/* now a macro */
+/* return ptr to little string in big string, NULL if not found */
+/* This routine was donated by Corey Satten. */
+
+char *
+Perl_instr(const char *big, const char *little)
+{
+ /* Porting tests require this macro to be used even though it doesn't exist
+ * (except for the commented-out version in proto.h). So provide a commented-out
+ * "use" of the prototype and supply a real version of what it expanded to.
+ PERL_ARGS_ASSERT_INSTR;
+ */
+ assert(big);
+ assert(little);
+
+ return strstr((char*)big, (char*)little);
+}

END_EXTERN_C

diff --git a/util.c b/util.c
index 89c44e7..447a19f 100644
--- a/util.c
+++ b/util.c
@​@​ -551,18 +551,6 @​@​ Perl_delimcpy(char *to, const char *toend, const char *from, const char *fromend
return (char *)from;
}

-/* return ptr to little string in big string, NULL if not found */
-/* This routine was donated by Corey Satten. */
-
-char *
-Perl_instr(const char *big, const char *little)
-{
-
- PERL_ARGS_ASSERT_INSTR;
-
- return strstr((char*)big, (char*)little);
-}
-
/*
=head1 Miscellaneous Functions


2.2.1

$ perl -"V"
Summary of my perl5 (revision 5 version 23 subversion 10) configuration​:
Snapshot of​: c349b9a
Platform​:
osname=VMS, osvers=V8.4, archname=VMS_IA64
uname='VMS alma V8.4 HP rx2600 (1.50GHz/6.0MB)'
config_args='-"Dusedevel" -"DDEBUGGING" -"Dusevmsdebug" -"Dusecxx" -"Duser_c_flags=/WARN=INFORMATIONAL=NOCTOBUTCONREFM" -"des"'
hint=none, useposix=false, d_sigaction=define
useithreads=undef, usemultiplicity=undef
use64bitint=undef, use64bitall=undef, uselongdouble=undef
usemymalloc=undef, bincompat5005=undef
Compiler​:
cc='CXX', ccflags ='/Include=[]/Standard=ANSI/Prefix=All/Obj=.obj /NOANSI_ALIAS/float=ieee/ieee=denorm/NAMES=(SHORTENED)/WARN=INFORMATIONAL=NOCTOBUTCONREFM/Define=_USE_STD_STAT=1',
optimize='/List/Debug/NoOpt',
cppflags='undef'
ccversion='70490005', gccversion='', gccosandvers='undef'
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234, doublekind=3
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16, longdblkind=1
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries​:
ld='Link/nodebug', ldflags ='/Debug/Trace/Map'
libpth=/sys$share /sys$library
libs=
perllibs=
libc=(DECCRTL), so=exe, useshrplib=true, libperl=undef
gnulibc_version='undef'
Dynamic Linking​:
dlsrc=dl_vms.xs, dlext=exe, d_dlsymun=undef, ccdlflags=''
cccdlflags='', lddlflags='/Share'

Characteristics of this PERLSHR image​:
Compile-time options​: DEBUGGING HAS_TIMES HAVE_INTERP_INTERN PERLIO_LAYERS
PERL_COPY_ON_WRITE PERL_DONT_CREATE_GVSV
PERL_EXTERNAL_GLOB PERL_HASH_FUNC_ONE_AT_A_TIME_HARD
PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PERL_USE_DEVEL
USE_IEEE USE_LARGE_FILES USE_LOCALE
USE_LOCALE_COLLATE USE_LOCALE_CTYPE
USE_LOCALE_NUMERIC USE_LOCALE_TIME USE_PERLIO
USE_PERL_ATOF VMS_DO_SOCKETS
VMS_SHORTEN_LONG_SYMBOLS
Built under VMS
Compiled at Apr 6 2016 23​:54​:00
%ENV​:
PERLSHR="perl_root​:[000000]perlshr.exe"
PERL_ROOT="DSA0​:[craig.blead.]"
@​INC​:
/perl_root/lib/site_perl/VMS_IA64
/perl_root/lib/site_perl
/perl_root/lib/VMS_IA64/5_23_10
/perl_root/lib
.

@p5pRT
Copy link
Author

p5pRT commented Apr 7, 2016

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Apr 7, 2016

From @craigberry

On Apr 7, 2016, at 10​:05 AM, karl williamson via RT <perlbug-followup@​perl.org> wrote​:

On 04/07/2016 06​:08 AM, Craig A. Berry (via RT) wrote​:

# New Ticket Created by Craig A. Berry
# Please include the string​: [perl #127852]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=127852 >

Sending to the list because of code freeze, but I think it should be a 5.24.0 blocker since it fixes a new problem we created within the last month. Patch inline and attached.

Maybe we should just revert that for 5.24

That works for me. I wasn’t sure if anything else depended on it.

@p5pRT
Copy link
Author

p5pRT commented May 18, 2016

From @khwilliamson

This was re-inserted in blead in
534dad4

and the special cases needed were removed, once the infrastructure was in place,
by fb24590
--
Karl Williamson

@p5pRT
Copy link
Author

p5pRT commented May 18, 2016

@khwilliamson - Status changed from 'open' to 'pending release'

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

From @khwilliamson

Thank you for filing this report. You have helped make Perl better.

With the release today of Perl 5.26.0, this and 210 other issues have been
resolved.

Perl 5.26.0 may be downloaded via​:
https://metacpan.org/release/XSAWYERX/perl-5.26.0

If you find that the problem persists, feel free to reopen this ticket.

@p5pRT
Copy link
Author

p5pRT commented May 30, 2017

@khwilliamson - Status changed from 'pending release' to 'resolved'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant