Link-time and post-link optimizations

I’ve tried several traditional linker optimizations on cperl recently. The easiest is LTO or “Link Time Optimization” via gcc -flto=4 or clang -flto=thin. This requires the gold linker, and enables multi-threaded link-time optimizations. For gcc my configure script does CC=${CC:-ccache gcc} ./Configure -sder -Dcc="$CC" \ -Dld="$CC -fuse-linker-plugin" \ -Accflags="-flto=4 -fuse-ld=gold -msse4.2 -march=native" ... and for clang CC=${CC:-ccache clang-7} ./Configure -sder -Dcc="$CC" \ -Dranlib=llvm-ranlib-7 -Dar=llvm-ar-7 -Dfull_ar=/usr/bin/llvm-ar-7 \ -Accflags="-DLTO -flto=thin -msse4.

Read More

Removal of the perl4 ' package seperator

The removal of the old and deprecated perl4 single quote character ' as valid package seperator in cperl went through various steps. It’s also explained in perldata. There are still two package separators in perl5: A double colon (::) and a single quote ('). Normal identifiers can start or end with a double colon, and can contain several parts delimited by double colons. Single quotes within perl5 have similar rules, but with the exception that they are not legal at the end of an identifier: That is, $'foo and $foo'bar are legal, but $foo'bar' is not.

Read More

There be getcwd dragons

The Cwd perl5 module contains various functions to return the string of the current working directory. The POSIX API only contains getcwd(), some provide also getwd() - ignored in perl, and the glibc also provides get_current_dir_name() and supports a NULL argument for getcwd(char *buf, size_t size). The Cwd module adds cwd, getcwd, getdcwd for Windows with a drive letter, fastcwd, fastgetcwd. symlinks The simplify the explanation of the various variants, which in theory should all return the same string, consider symlinks.

Read More

cperl classes

Subtitle: Why a MOP is not always a good idea cperl being a perl11, i.e. 5+6=11, of course means that cperl classes are designed after perl5 and perl6 classes. perl5 does not have a builtin class keyword, but allows to add keywords to be added at runtime. cperl and perl6 of course do have a builtin class keyword. The backcompat problem with a new builtin keyword is, that some usages of variables, package or function names will not work anymore, because the new keyword stepped over it.

Read More

safeclib-3.3 and its new compile-time checks

In the previous “The sad state of foldcase and string comparisons” article I already mentioned my safeclib library improvements, for the surpringly rather unique ability to search for strings (with Unicode support). With the recent safeclib-3.3 release I made the almost same improvements as in cperl: Adding lots of compile-time checks and seperating them out of the run-time. Do less branching at run-time when the compiler can already prove that a certain branch or check was already done at compile-time.

Read More

The sad state of foldcase and string comparisons

You probably heard about case-folding or foldcase before. Unicode defines CaseFolding mappings for some upper-case characters, which in full casefolding mode will expand some exotic characters to larger sequences. In simple mode it will do 1:1 tolower() mappings. The perl documentation has this to say: fc Returns the casefolded version of EXPR. This is the internal function implementing the “\F” escape in double-quoted strings. Casefolding is the process of mapping strings to a form where case differences are erased; comparing two strings in their casefolded form is effectively a way of asking if two strings are equal, regardless of case.

Read More

Attribute arguments

perl5 had broken attribute handling forever perl5 attributes were invented to provide extendable hooks to attach data or run code at any data, and made for nice syntax, almost resembling other languages. E.g. my $i :Int = 1; sub calc :prototype($$) { shift + shift } There were a few number of builtin attributes, like :lvalue, :shared, :const, adding a flag to a function or data, and you could add package-specific for compile-time or run-time hooks to process arbitrary custom attributes.

Read More

strict names

Consistent identifier parsing rules perl5 and cperl older than 5.27.0 accepts any string as valid identifier name when being created under no strict 'refs' at run-time, even when most such names are illegal, and cannot be handled by most external modules. Even invalid unicode is allowed. cperl 5.26 fixed embedded NUL’s and invalid unicode identifiers illegal, and normalizes unicode identifiers in the parser. Since cperl 5.27.1 dynamically created names are treated the same way as when they are parsed.

Read More

strict hashpairs

perl5 optionally warns on odd hash elements my %h = (0,1,2); is legal code in perl5. The second pair is constructed with the undef value. With use warnings 'misc' it will warn at least. use warnings; my %h = (0,1,2); => Odd number of elements in hash assignment (WARNING only) perl6 throws on odd hash elements perl6 is sane and strict by default. my %h = (0..2); => Odd number of elements found where hash initializer expected: Found 3 (implicit) elements: Last element seen: 2 in block <unit> at <unknown file> line 1 cperl 5.

Read More

Automatic cperl deployments

Binary packages perl5 relies on external packagers to update and maintain packages for various distributions. It only provides source packages as tarballs. cperl does a bit better by also providing binary packages for all major platforms. See also Installation at the STATUS page. win32, win64, debian 7 i686, debian 8 amd64, centos 7 x86_64, centos 6 i686+x86_64 and darwin amd64. Packaging was done with this do-make-cperl-release script, leading to

Read More