cmake - Yocto 中未从生成的二进制文件中删除的调试符号
问题描述
背景
我正在尝试在 Yocto build 中构建自定义软件。软件由 CMake 构建。
以下是我的食谱 - customsoftware.bb
:
SRCBRANCH = "master"
SRCREV = "master"
MY_SRC = "OMITTED"
SRC_URI = "${MY_SRC};branch=${SRCBRANCH}"
# libraries dependencies
DEPENDS += "boost"
S = "${WORKDIR}/git"
B = "${WORKDIR}/build"
PARALLEL_MAKE ?= "-j 1"
inherit cmake
# My CMake Options
EXTRA_OECMAKE+=" -DSOME_OPTION=ON"
# I want unix makefiles instead on ninja build
OECMAKE_GENERATOR="Unix Makefiles"
以下是我的 cmake 项目的淡化版本 -CMakeLists.txt
请注意:为简洁起见,我省略了不相关的部分
cmake_minimum_required(VERSION 3.0.0)
#---------------------------------------------------------------------------------------
# set default build to release
#---------------------------------------------------------------------------------------
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose Release or Debug" FORCE)
endif()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/dist/)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/dist/bin)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
if ("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
message(FATAL_ERROR "
${BoldRed}Error:${ColourReset} In-source builds are not allowed. You should create separate directory for build files.
${Magenta}CMAKE_BINARY_DIR${ColourReset}(${CMAKE_SOURCE_DIR}) must be different from ${Magenta}CMAKE_SOURCE_DIR${ColourReset}(${CMAKE_BINARY_DIR})
")
endif ()
project(myapp)
find_package(Boost REQUIRED COMPONENTS thread)
add_executable(${PROJECT_NAME}
${HEADERS}
${SOURCES}
)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
#Copy entire contents of dist/ to /opt/myapp
install(DIRECTORY ${CMAKE_BINARY_DIR}/dist/
DESTINATION /opt/myapp
)
我已将我的食谱附加到图像中。
问题
当我运行du -h tmp/work/.../<customsoftware>/build/dist/bin
二进制大小是 80MB。此外,部署到目标系统后二进制大小为 80MB。
更新
正如评论中所建议的,二进制文件tmp/work/.../<customsoftware>/image
不会被剥离。但是,二进制文件 attmp/work/.../<customsoftware>/packages-split
被剥离。
如果我make
在应用程序源中运行 - 不是通过配方和外部 yocto - 二进制大小为 1.7MB
问题
如果我没记错的话,OE 构建将从生成的二进制文件中删除调试符号。
为什么我的二进制文件仍然使用调试符号进行部署?我错过了什么?
我怎样才能确保只部署了剥离 - 发布类型 - 二进制文件?
解决方案
您能否尝试看看这个简单的 Hello World 是否在您的环境中被剥离?
食谱:
DESCRIPTION = "Simple helloworld cmake"
LICENSE = "MIT"
SECTION = "examples"
LIC_FILES_CHKSUM =
"file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://CMakeLists.txt \
file://helloworld.c"
S = "${WORKDIR}"
inherit cmake
EXTRA_OECMAKE = ""
CMakeLists.txt:
cmake_minimum_required(VERSION 2.8.10)
project(helloworld)
add_executable(helloworld helloworld.c)
install(TARGETS helloworld RUNTIME DESTINATION bin)
你好世界.c:
#include <stdio.h>
int main() {
printf("Hello World Makefile from CMake!\n");
return(0);
}
推荐阅读
- c# - 找不到字段:“Microsoft.EntityFrameworkCore.Metadata.Internal.EntityMaterializerSource.ThrowReadValueExceptionMethod”
- xpath - 使用 XPath 捕获部分文本
- python - 无法将简单的烧瓶应用程序部署到 azure Web 应用程序
- python - 原始字符串和 repr() 是等价的吗?
- bash - 如何将参数中的空格传递给变量中的命令
- node.js - 将 AWS ElasticBeanstalk 用于后台任务是否安全?(无法通过 HTTP 访问前端)
- python - ValueError:检查目标时出错:预期 conv2d_19 的形状为 (None, 320, 320, 1) 但得到的数组的形状为 (18, 320, 320, 2)
- java - 线程“main”中的异常 java.util.NoSuchElementException 和 java.util.Scanner 错误
- angular - 如何在 UML 中为 typescript 接口的实例建模
- php - 如何阻止用户访问我网站的目录路径?