buntyshubho has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,

I was playing around with the source files of perl, downloaded from CPAN. After building a local copy of the interpreter (using ./Configure, make, make-test, make install), I was curious to find which source files actually went into the build itself.

I do not want the files that were provided with the download of source but are not needed for the default build (eg: apollo/netinet/in.h..deleting this file does not affect my build)

I tried a technique that works with normal gcc compilations. In this, I declared a string in all the source files and looked at the Hex dump to find out the strings (and used 'strings' shell command as well). This technique worked successfully on dummy c files that I made for testing. But it does not seem to work on perl source files themselves.

I was wondering if there is any way I can find out all the source files that go into building perl?

Thanks
  • Comment on Source files going into perl interpreter during compilation

Replies are listed 'Best First'.
Re: Source files going into perl interpreter during compilation
by Corion (Patriarch) on Jun 21, 2011 at 21:16 UTC

    If this is just idle interest, the files are all the .c files in the root directory of the distribution, and all the files from the directory for your OS, plus some from ext/ for extensions built into Perl statically (depending on what you answered in ./Configure).

    If you have a practical goal you are pursuing, maybe make miniperl or make microperl (resp. the targets in the generated Makefile) or App::staticperl may be of interest to you.

      Thanks.

      I do know how to use a local installation of perl for a practical application after building it myself.

      Let's say I use the default ./Configure settings and build the interpreter. I know it uses some .c files from root distribution directory and some standard library files etc....What I'd like to know if there any way I can point out exactly which .c and .h files (inside the root directory of distribution) were used for the build?

      Thanks
Re: Source files going into perl interpreter during compilation
by BrowserUk (Patriarch) on Jun 21, 2011 at 22:10 UTC
    used 'strings' shell command as well).... But it does not seem to work on perl source files themselves

    Did you only run strings on the perl executable, or on libperl.xo also?

    Have you considered using the #warning "some text here" directive to identify the files that are process during compilation?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.
      ^^Thanks a lot. That was really good.

      So, I tried working with .o files and used "strings" on all of those. Basically, what I have done is inserted the following right at the bottom of each .c and .h file.

      static char *a = "Filename";

      But because it is defined as static, those strings don't show up using strings command (in .so as well as the executable). Why? I do not know myself. It works when I do that for dummy files.

      When I remove the static keyword,there are linker issues showing redefinitions all over the place.

      #warnings was an interesting idea and I tried it out just now. It's successful in the sense that it does print out the warnings along with all the other compiler messages.

      But, I cannot make it output to a file so I can analyze it. No, redirection ( make > makelog.txt) is not working.

      This is getting really interesting. Any further help will be greatly appreciated.

      Thanks
        But because it is defined as static, those strings don't show up using strings command (in .so as well as the executable). Why? I do not know myself. It works when I do that for dummy files.

        Perhaps because Perl compiles with optimisation turned on, and unless those strings where referenced somewhere, they'll just be omptimised away.

        But, I cannot make it output to a file so I can analyze it. No, redirection ( make > makelog.txt) is not working.

        Have you tried make 2>&1 > make.log?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.