3

Please understand I'm using Autotools / Automake / Autoconf, and I can not use redirection because it needs to be applied command by command in the make file generated by autotools.

I need a way for to have autotools create a make file which has provisions for generating and saving the compiler and/or assembler listings associated with each individual source in the package.

My first try was to add '-Wa,-acdhln -g' into CCFLAGS. This indeed produced a composite c/assembler listing, but it went to the terminal, not into a file. If I captured the make output (using redirection), I would have 47 different listings strung all together along with interspersed build commands.

What I hoped would happen, optimistically reading the GCC doc Overall Options - Using the GNU Compiler Collection,

-o file
Place output in file file. This applies to whatever sort of output is being produced, whether it be an executable file, an object file, an assembler file or preprocessed C code.

If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, its assembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.

is for files {file}.o, and {file}.s to appear, based on the "-o {file}.o" in the GCC command line.

What happened is that the assembly listing was apparently sent to standard output.

EDIT to add 23 Oct 2016. I now realize the documentation was talking about thing like the compiler output file passed as input to the assembler, and the assembler output file passed as input to the linker. Neither would be the assembler LISTING file which I want to capture.

This also applies to the using the -save-temps option; it would only save the output from the assembler, which is the linker input file, not the assembler listing file.

  • An alternate interpretation of the doc could imply that every output file would be placed in the one single file named in the -o operand, either intermixed, or with the last created file overlay previously created files. (For example, the output from the compiler pass overlayed with the output from the assembler pass overlayed with the output from the collection pass.)

    As this seems to be counter productive, I assumed that GCC (the top level executive) might be smart enough to adjust the file name for different passes. This does not seem to be true.

  • Omitting the file name from the "-o" would seem to exactly what is wanted, save that the object file is always named "a.out" instead of "{source}.o". Why a constant for the source output name was chosen makes no sense to me, but a rename step after each GCC invocation could change "a.out" to "{source}.o".

  • Consulting the GNU Assembler documentation says even less about -o, and has no option for dealing with the output listing. One assembler version, tigcc, documents that the listing is emitted as standard output.

    • Did the GNU and GNU Build Standard revisions to Unix not address this?

    • (Am I insane, or am I just living in an un-reality called Unix? ? ?)

So now it looks like Make needs to tell GCC that when the assembly step is executed, that standard output should be placed in the $@.s file. I suspect this can't be done, given how the GCC options appear to behave (and a quick look at how specs files are used). Perhaps Automake (or libtools?) can create a multi-stepped compile operation, separating out the various steps out so the assembly output can be captured.

But, since the make file is generated by autotools, I need a way to tell autotools to create the make file that will create/capture the assembly output file. This task would seem to require re-writing some of the autoconf/automake rules and/or macros.

Finally, I'm working with a package someone else created using autotools, tar-balled up and downloaded to me. I didn't do the autotools packaging, and I didn't create the giant *.ac files, and I don't want to hack on them, if at all avoidable.

I just need to get some assembly and link maps to try and debug a problem with the package.

  • Have you looked into the gcc option -save-temps? AFAICT, this may be what you want. – Bjorn A. Oct 22 '16 at 11:23
  • @Bjorn Sorry to report that -save-temps only saved the INPUT to the assembler, not the output listing. Actually, you need -save-temps=obj, otherwise the intermediates may not be saved in the same directory as the object (which generally follows the source in most generated commands). There is a warning about running multiple compiles at the same time and have the intermediate files interleaved when the =obj form is NOT used. That bothered me enough that I added MAKEJOBS=1 to the "make all" and "make install" commands in my script. – HiTechHiTouch Oct 23 '16 at 10:54
1

I finally broke down and wrote a real program that analyzed the captured terminal output and extracted the listing files. While it works for my specific system / build configuration / package, I can't offer it as anything more than an example. It's certainly not a readily usable tool.

I'm sorry this really isn't a general answer to overcoming an autotools short coming.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.