openbmc / docs

OpenBMC Documentation
Creative Commons Attribution 4.0 International
277 stars 307 forks source link

Ninja build error #75

Closed hayleyyan closed 2 years ago

hayleyyan commented 2 years ago

I'm following the development documentation, and has successfully finish the development environment setup. I am running into an issue in OpenBMC Hello World in SDK, particularly in the steps to run (https://github.com/openbmc/docs/blob/master/development/sdk-hello-world.md#clone-and-build-a-repo):

meson build
ninja -C build 

After running ninja -C build it returns the follow:

Screen Shot 2022-06-08 at 12 14 33 PM

I have tried installing cereal and cmake but neither seem to resolve the error.

Any suggestions on how I can resolve this error?

williamspatrick commented 2 years ago

None of those look like warnings. Is there more to the build log?

Please upload text to a service like gist.github.com (or paste here) rather than attempting to take screenshots.

hayleyyan commented 2 years ago

Here's the full output when i run ninja -C build https://gist.github.com/hayleyyan/4f352a884c4cc45eeee1afb0f4b4da04

williamspatrick commented 2 years ago

It seems like the only warning is this:

/root/sdk/romulus-2022-06-06/sysroots/arm1176jzs-openbmc-linux-gnueabi/usr/include/features.h:412:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
  412 | #  warning _FORTIFY_SOURCE requires compiling with optimization (-O)
      |    ^~~~~~~

I'm not sure why that is present since it appears that the compiler call includes -O2: arm-openbmc-linux-gnueabi-g++ -marm -mcpu=arm1176jz-s -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/root/sdk/romulus-2022-06-06/sysroots/arm1176jzs-openbmc-linux-gnueabi -Iphosphor-hypervisor-state-manager.p -I. -I.. -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wnon-virtual-dtor -Wextra -Wpedantic -Werror -std=c++20 -O0 -g -DENABLE_WARM_REBOOT -DBOOST_ASIO_DISABLE_THREADS -DBOOST_ALL_NO_LIB -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_ERROR_CODE_HEADER_ONLY -DBOOST_COROUTINES_NO_DEPRECATION_WARNING -MD -MQ phosphor-hypervisor-state-manager.p/hypervisor_state_manager_main.cpp.o -MF phosphor-hypervisor-state-manager.p/hypervisor_state_manager_main.cpp.o.d -o phosphor-hypervisor-state-manager.p/hypervisor_state_manager_main.cpp.o -c ../hypervisor_state_manager_main.cpp

@geissonator Any ideas on this? I don't see anything obviously wrong from the phosphor-state-manager's meson.build.

@hayleyyan In the short term you could probably get rid of these two lines in the meson.build:

        'warning_level=3',
        'werror=true',

https://github.com/openbmc/phosphor-state-manager/blob/master/meson.build#L5

williamspatrick commented 2 years ago

Oh... There is a -O2 and then later there is a -O0. Any ideas where the -O0 is coming from? Have you set any CFLAGS or CXXFLAGS environment variables? Can you also check if the SDK set any of them?

hayleyyan commented 2 years ago

I didn't set any of those environment variables but it seems the SDK have set them to the following:

echo $CFLAGS
-O2 -pipe -g -feliminate-unused-debug-types

echo $CXXFLAGS
-O2 -pipe -g -feliminate-unused-debug-types
manojkiraneda commented 2 years ago

@hayleyyan which build type are u trying to build ? wonder if it is coming due to meson's default build debug which comes with -O0

As phosphor-state-manager does not implicitly defaulted the build type to debugoptimized(comes with -O2) , it might be taking the meson's default build type debug (comes with -O0), but the SDK what you would have sourced in implicitly would have added an -O2 in the CXXFLAGS environmental variable which is why you probably see both optimization's in the build log.

Can you try building with meson build -Dbuildtype=debugoptimized to see if the error goes away ?

hayleyyan commented 2 years ago

@manikandan-e i'm building on romulus. Here's the output with meson build -Dbuildtype=debugoptimized

https://gist.github.com/hayleyyan/8778ba844a9e7e789f01f3dab5df4f0a

williamspatrick commented 2 years ago

@manikandan-e i'm building on romulus. Here's the output with meson build -Dbuildtype=debugoptimized

https://gist.github.com/hayleyyan/8778ba844a9e7e789f01f3dab5df4f0a

Seems good now... There is just a warning about an unused variable.

hayleyyan commented 2 years ago

When i'm trying to do the next command in Load the Application Into QEMU, it's returning the following:

root@hayley-VirtualBox:/home/hayley/repo/phosphor-state-manager/build# arm-openbmc-linux-gnueabi-strip phosphor-bmc-state-manager
arm-openbmc-linux-gnueabi-strip: 'phosphor-bmc-state-manager': No such file

Here's all the files I have under build:

build.ninja                            phosphor-chassis-state-manager.p      phosphor-secure-boot-check.p
compile_commands.json                  phosphor-discover-system-state        phosphor-systemd-target-monitor
config.h                               phosphor-discover-system-state.p      phosphor-systemd-target-monitor.p
data                                   phosphor-host-reset-recovery          service_files
meson-info                             phosphor-host-reset-recovery.p        target_files
meson-logs                             phosphor-host-state-manager           test_hypervisor_state.p
meson-private                          phosphor-host-state-manager.p         test_scheduled_host_transition.p
phosphor-bmc-state-manager.p           phosphor-hypervisor-state-manager     test_systemd_parser.p
phosphor-chassis-check-power-status    phosphor-hypervisor-state-manager.p   test_systemd_signal.p
phosphor-chassis-check-power-status.p  phosphor-scheduled-host-transition
phosphor-chassis-state-manager         phosphor-scheduled-host-transition.p

Seems like some files were built but some weren't?

williamspatrick commented 2 years ago

Seems like some files were built but some weren't?

../bmc_state_manager_main.cpp: In function ‘int main(int, char**)’:
../bmc_state_manager_main.cpp:9:14: error: unused parameter ‘argc’ [-Werror=unused-parameter]
    9 | int main(int argc, char**)
      |          ~~~~^~~~
cc1plus: all warnings being treated as errors

Unless you fixed this, then the phosphor-bmc-state-manager seemed to fail. Should be a pretty straight-forward fix for you...