libspdm icon indicating copy to clipboard operation
libspdm copied to clipboard

test_size_of_spdm_requester dosent works on Linux

Open alokprasad opened this issue 3 years ago • 5 comments

1.Any particular reason why test_size_of_spdm_* is not added under Linux and only for windows. CMakelists.txt

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
    if(ARCH STREQUAL "x64")
       if(NOT TOOLCHAIN STREQUAL "LIBFUZZER")
        ADD_SUBDIRECTORY(unit_test/test_size/test_size_of_spdm_requester)
        ADD_SUBDIRECTORY(unit_test/test_size/test_size_of_spdm_responder)
        endif()
    endif()
endif()
  1. If i remove windows check and build for Linux with all the configs enable in spdm_lib_config.h i see that size comes to around 1.2K does this size make sense?
[root@neutron libspdm]# ls -alh ./build/bin/test_size_of_spdm_responder
-rwxr-xr-x. 1 root root 1.2K Feb 10 05:51 ./build/bin/test_size_of_spdm_responder

[root@neutron libspdm]# file ./build/bin/test_size_of_spdm_responder
./build/bin/test_size_of_spdm_responder: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, BuildID[sha1]=a0f98b7c0eebe8603b9882fec30bed3a27de71b4, not stripped

alokprasad avatar Feb 10 '22 11:02 alokprasad

It is OK to turn on for GCC, if you have send a PR. (it is just not enabled before.)

The MSVC data is shown at https://github.com/DMTF/libspdm/discussions/603.

1.2K is too big. It does not make sense at all.

Is it release build, with size optimization, and link time optimization?

jyao1 avatar Feb 10 '22 11:02 jyao1

@jyao1 1.2k is too small rather I thought? https://github.com/DMTF/libspdm/discussions/603 also show minimum size as 22k yes its release build.

unit_test/test_size/test_size_of_spdm_responder/CMakeLists.txt uses below flags. SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -nostdlib -Wl,-n,-q,--gc-sections -Wl,--entry,ModuleEntryPoint")

I cannot add -Os or -flto as it throw errs

alokprasad avatar Feb 10 '22 14:02 alokprasad

Sorry, I thought it is 1.2M. 1.2k is too small, definitely.

Just checked the code, I use

#if defined(_MSC_EXTENSIONS)
#pragma optimize("", off)
#endif

I think we may need GCC way to turn off opt for this specific file.

jyao1 avatar Feb 10 '22 14:02 jyao1

in Main CMakelists.txt we are using -flto -DUSING_LTO whic will removes all the function not used hence size is small. if i remove them compilation fails , to proceed i have to comment printf inside debug_print debug_assert /os_stub/deb(uglib/debuglib.c)

which that seeing the size as 270k . will check more on this...

alokprasad avatar Feb 10 '22 17:02 alokprasad

270K is full feature + no encryption? that is big.

Maybe you can help check the symbol to see if any unnecessary functions are included.

jyao1 avatar Feb 10 '22 23:02 jyao1

This was fixed by #1320.

steven-bellock avatar Jul 12 '24 15:07 steven-bellock