Re: How to have a default specs file config file?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



all of the below appears to be intentional, but also confusing, and
not documented. Will send some RFC proposals.

On Thu, Sep 5, 2024 at 6:46 PM Dimitri Ledkov
<dimitri.ledkov@xxxxxxxxxxxxxx> wrote:
>
> Ideally I want to append flags to the default gcc specs file, and set
> flags there, without rebuilding GCC toolchain.
>
> I started with a simple specs file which only does:
>
> ```
> *self_spec:
> + -fhardened
> ```
>
> When invoking g++-14 like this:
>
> $ g++-14 -v -specs ./specs /dev/zero
>
> Things are fine, specifically the flag I specified is in effect, as in:
>
> COLLECT_GCC_OPTIONS='-v' '-specs=./specs' '-foffload-options=-l_GCC_m'
> '-shared-libgcc' '-mtune=generic' '-march=x86-64' '-fhardened'
> '-dumpdir' 'a.'
>
> has -fhardened, and the rest of the options are correct too.
> Specifically the command ends with "/dev/zero -lstdc++ -lm -lgcc_s
> -lgcc -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/14/crtendS.o
> /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/crtn.o" as
> expected
>
> Once I was very happy with this spec, I was hoping that I can move
> this specs file into /usr/lib/gcc/x86_64-linux-gnu/14/specs such that
> it will be always activated.... and it did.
>
> Reading specs from /usr/lib/gcc/x86_64-linux-gnu/14/specs
> COLLECT_GCC_OPTIONS='-v' '-foffload-options=-l_GCC_m' '-shared-libgcc'
> '-mtune=generic' '-march=x86-64' '-fhardened' '-dumpdir' 'a.'
> And so on.
>
> But I got an unexpected side-effect. As the overall command now ends with
> "/dev/zero -lstdc++ -lm -lgcc -lc -lgcc
> /usr/lib/gcc/x86_64-linux-gnu/14/crtendS.o
> /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/crtn.o"
>
> Notice how the libraries between /dev/zero and crtendS.o are now
> different with -lgcc_s now gone.
>
> If I add into specs file this snippet from dumpspecs
>
> ```
> *libgcc:
> %{static|static-libgcc|static-pie:-lgcc
> -lgcc_eh}%{!static:%{!static-libgcc:%{!static-pie:%{!shared-libgcc:-lgcc
> --push-state --as-needed -lgcc_s
> --pop-state}%{shared-libgcc:-lgcc_s%{!shared: -lgcc}}}}}
> *self_spec:
> + -fhardened
> ```
>
> The command lines generate now look as before. But I fear that my
> modifications to "specs" like that is not a good way of doing this. It
> seems like it may need to include full contents of "dumpspecs" in
> addition to any further customisations, and it really is not
> equivalent to a "default built-in location equivalent to -specs arg".
>
> Is this expected? Is  /usr/lib/gcc/x86_64-linux-gnu/14/specs not a
> good place to do self_spec override? Is there any other way to preset
> default self_spec? Should I do something else - i.e. configure GCC
> using `--with-specs=%:include(myspecs)` and then ensure said file
> always exists, and specify custom flags there?
>
> Ultimately I am trying to experience similarish to clang toolchain
> which allows creating .cfg file with any custom commandline settings.
>
> Regards,
>
> Dimitri.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux