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

SF#392 Inline Pdlpp doesn't work in clean build tree #126

Closed
zmughal opened this issue Jun 17, 2015 · 6 comments
Closed

SF#392 Inline Pdlpp doesn't work in clean build tree #126

zmughal opened this issue Jun 17, 2015 · 6 comments

Comments

@zmughal
Copy link
Member

zmughal commented Jun 17, 2015

From http://sourceforge.net/p/pdl/bugs/392/

This is probably a side effect of some cleverness but the attached script runs fine outside of a pdl-code/ repository as well as in the top directory---as long as the tree has been compiled. Otherwise we get the following error:

Running Mkbootstrap for FtoC_pdl_2e4d ()
chmod 644 FtoC_pdl_2e4d.bs
/usr/bin/perl.exe "-I/cygdrive/f/chm/pdl/git/pdl-code" "-MPDL::PP qw/FtoC_pdl_2e4d FtoC_pdl_2e4d FtoC_pdl_2e4d/" FtoC_pdl_2e4d.pd
touch FtoC_pdl_2e4d.xs
/usr/bin/perl.exe /cygdrive/f/perl/local64/lib/perl5/ExtUtils/xsubpp -typemap /usr/lib/perl5/5.14/ExtUtils/typemap -typemap /usr/lib/perl5/5.14/ExtUtils/typemap -typemap /cygdrive/f/chm/pdl/git/pdl-code/Basic/Core/typemap.pdl FtoC_pdl_2e4d.xs > FtoC_pdl_2e4d.xsc && mv FtoC_pdl_2e4d.xsc FtoC_pdl_2e4d.c
gcc -c "-I/cygdrive/f/chm/pdl/git/pdl-code/Basic/Core" -DPERL_USE_SAFE_PUTENV -USTRICT_ANSI -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.14.4-3 -fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.14.4=/usr/src/debug/perl-5.14.4-3 -fwrapv -fno-strict-aliasing -fstack-protector -DUSEIMPORTLIB -O3 -DVERSION=\"0.00\" -DXS_VERSION=\"0.00\" "-I/usr/lib/perl5/5.14/x86_64-cygwin-threads/CORE" FtoC_pdl_2e4d.c
FtoC_pdl_2e4d.xs:24:17: fatal error: pdl.h: No such file or directory
#include "pdl.h"
^
compilation terminated.
Makefile:336: recipe for target 'FtoC_pdl_2e4d.o' failed
make: *** [FtoC_pdl_2e4d.o] Error 1

A problem was encountered while attempting to compile and install your Inline
Pdlpp code. The command that failed was:
"make > out.make 2>&1" with error code 2

The build directory was:
/cygdrive/f/chm/pdl/git/pdl-code/_Inline/build/FtoC_pdl_2e4d

To debug the problem, cd to the build directory, and inspect the output files.

Environment PATH = '/cygdrive/f/perl/local64/bin:/usr/local/bin:/usr/bin'
Environment PATHEXT = '.PY;.PYW'
at FtoC.pdl line 18.
...propagated at /cygdrive/f/perl/local64/lib/perl5/Inline/C.pm line 864.
BEGIN failed--compilation aborted at FtoC.pdl line 39.

Since it was more of a "surprise, what's up?" I've marked this as low priority.

@mohawk2
Copy link
Member

mohawk2 commented Apr 9, 2018

Sorry, I opened #231 since I missed the existence of this! I'll close that in favour of this and put my comment here.

@mohawk2
Copy link
Member

mohawk2 commented Apr 9, 2018

@devel-chm There was no attached script; could you provide one? :-)

@mohawk2
Copy link
Member

mohawk2 commented Dec 13, 2019

This is impossible to repro without a script and a method of seeing the error. Possibly you'd work around it by using the perl -IBasic/Gen. Therefore closing.

@mohawk2 mohawk2 closed this as completed Dec 13, 2019
@d-lamb
Copy link
Member

d-lamb commented Jun 22, 2020

Attached is a script that triggers this error. I had assumed the 'FtoC' in @devel-chm's original report was 'Fortran-to-C', and it was hopeless to ever reproduce it. But probably 'FtoC' was the 'Fahrenheit-to-Celsius' dataflow example code from Section 5.1 of Practical Magick with C, PDL and PDL::PP.

Here is the output of running the script in the home directory, and in the 'realclean' PDL build directory. Note that the script in the home directory is a symlink to the script in the PDL build directory, so there's no difference in the code.

derek@simurgh:~$ rm -rf _Inline/
derek@simurgh:~$ ls -l pp_dataflow.pdl
lrwxr-xr-x  1 derek  staff  38 Jun 22 11:52 pp_dataflow.pdl -> /Users/derek/Build/PDL/pp_dataflow.pdl
derek@simurgh:~$ perl pp_dataflow.pdl
Name "main::FtoC" used only once: possible typo at pp_dataflow.pdl line 26.
0
33.8 F = 0.999999999999998 C
34.8 F = 1.55555555555555 C
derek@simurgh:~$ cd /Users/derek/Build/PDL/
derek@simurgh:PDL$ rm -rf _Inline/
derek@simurgh:PDL$ perl pp_dataflow.pdl 
Unable to find PDL's configuration info
 [Can't locate /Users/derek/Build/PDL/Basic/Core/Config.pm at (eval 17) line 1.
] at /Users/derek/local/lib/perl5/darwin-thread-multi-2level/PDL/Core/Dev.pm line 145.
Compilation failed in require at /Users/derek/local/lib/perl5/darwin-thread-multi-2level/Inline/Pdlpp.pm line 10.
BEGIN failed--compilation aborted at /Users/derek/local/lib/perl5/darwin-thread-multi-2level/Inline/Pdlpp.pm line 10.
Compilation failed in require at (eval 9) line 1.
Unable to find PDL's configuration info
 [Can't locate /Users/derek/Build/PDL/Basic/Core/Config.pm at (eval 17) line 1.
] at /Users/derek/local/lib/perl5/darwin-thread-multi-2level/PDL/Core/Dev.pm line 145.
Compilation failed in require at /Users/derek/local/lib/perl5/darwin-thread-multi-2level/Inline/Pdlpp.pm line 10.
BEGIN failed--compilation aborted at /Users/derek/local/lib/perl5/darwin-thread-multi-2level/Inline/Pdlpp.pm line 10.
Compilation failed in require at (eval 9) line 1.
Error. You have specified 'Pdlpp' as an Inline programming language.

I currently only know about the following languages:
    C, Foo, foo

If you have installed a support module for this language, try deleting the
config-darwin-thread-multi-2level-5.028002 file from the following Inline DIRECTORY, and run again:

    /Users/derek/Build/PDL/_Inline

(And if that works, please file a bug report.)

 at pp_dataflow.pdl line 5.
BEGIN failed--compilation aborted at pp_dataflow.pdl line 5.
derek@simurgh:PDL$ 

pp_dataflow.pdl.txt

@d-lamb d-lamb reopened this Jun 22, 2020
@mohawk2
Copy link
Member

mohawk2 commented Mar 13, 2021

@d-lamb Thanks for digging this out!

In fact, this can be reduced to this script:

use Inline Pdlpp => q{pp_def('add', Pars => 'a(); [o]c();', Code => '$c() = $a() + 1;');};

The error message above shows what's happening; PDL::Core::Dev has special handling for when it's run within the source tree, as it has to in order to work during the build of PDL. However, it assumes the initial configuration has been done by running Makefile.PL. Inline::Pdlpp also needs pdl.h etc to exist in order to actually make the code work, so just running Makefile.PL isn't enough.

I think it would create a lot of work and also risk, for a very minimal benefit, to change PDL::Core::Dev to handle this. Therefore, I will close this. But I'm very glad that we've actually been able to reproduce this in order to understand it!

@mohawk2 mohawk2 closed this as completed Mar 13, 2021
@mohawk2
Copy link
Member

mohawk2 commented Sep 25, 2021

Further analysis of this, prompted by needing PDL::Core::Dev to work very early in the build process in order to extract from .pd files their list of functions:

The whereami* functions need to distinguish between running when "installed" (in a PDL/Core/Dev.pm) and not (in a Basic/Core/Dev.pm) so that the right location could be used to load Config.pm, whose location varies between the two situations. Until now, this was done when asked, possibly after EUMM had chdir-ed away from the initial location in a build tree. Therefore the only workable strategy was to search upwards for a dev-tree root. This caused false positives as identified by this issue, albeit in a acceptably rare circumstance.

However, bd3f457 changes the strategy to one that is obvious in retrospect: capture where the Dev.pm actually lives at load-time using __FILE__, therefore pre-empting any chdir, and not needing (if it's "installed") to search the current directory tree. Now, as verified with the ongoing list-of-functions work, it now all works as it should.

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

No branches or pull requests

3 participants