toolchain icon indicating copy to clipboard operation
toolchain copied to clipboard

Newlib's libgloss is not optimized for size even if "--specs=nano.specs" are used

Open abrodkin opened this issue 4 years ago • 7 comments

Even if a user attempts to generate the smallest possible resulting binary specifying --specs=nano.specs board-specific libs like libnsim.a, libqemu.a etc are used from "normal" (non-"nano" build) of the Newlib, thus contributing to the resulting binary size.

abrodkin avatar Feb 16 '21 13:02 abrodkin

Why should we care about this? libnsim.a and libqemu.a are simulation only libraries. No reason to optimize them as they will never be used in production.

claziss avatar Feb 16 '21 19:02 claziss

Fair enough, though why do ARM folks do that for "semi-hosting"? See https://github.com/foss-for-synopsys-dwc-arc-processors/newlib/blob/arc-2021.03/libgloss/arm/elf-rdimon.specs#L14:

# rdimon.specs
#
# Spec file for AArch64 baremetal newlib with version 2 of the
# AngelAPI semi-hosting using the SVC trap instruction.

...

*rdimon_libgloss:
%{!specs=nano.specs:-lrdimon} %{specs=nano.specs:-lrdimon_nano}

What about libdw_uart.a, what if it is used in production?

abrodkin avatar Feb 16 '21 19:02 abrodkin

You need to ask them :)

claziss avatar Feb 16 '21 20:02 claziss

What about libdw_uart.a?

abrodkin avatar Feb 16 '21 20:02 abrodkin

And also even though we build & install "nano" version of libm.a (libm_nano.a) we don't replace -lm with lm_nano in `nano.specs, while RISCV folks do, see https://www.sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=libgloss/riscv/nano.specs:

*link:
%(nano_link) %:replace-outfile(-lc -lc_nano) %:replace-outfile(-lg -lg_nano) %:replace-outfile(-lm -lm_nano)

abrodkin avatar Feb 16 '21 21:02 abrodkin

What about libdw_uart.a?

My understanding is that you want to remove it (or refactor it?). You can pick this issue and make it part of your proposed solution.

claziss avatar Feb 17 '21 06:02 claziss

And also even though we build & install "nano" version of libm.a (libm_nano.a) we don't replace -lm with lm_nano in `nano.specs, while RISCV folks do, see https://www.sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=libgloss/riscv/nano.specs:

*link:
%(nano_link) %:replace-outfile(-lc -lc_nano) %:replace-outfile(-lg -lg_nano) %:replace-outfile(-lm -lm_nano)

libm is not libgloss :) Of course you can add a simple patch that is doing this.

claziss avatar Feb 17 '21 06:02 claziss