Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: asanitize address protobuf linkage #3026

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions cmake/modules/BaseConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ endif()
if(ASAN_ENABLED)
log_option_enabled("asan")
if(MSVC)
string(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
add_compile_options(/fsanitize=address)
link_libraries(-fsanitize=address)
else()
add_compile_options(-fsanitize=address)
link_libraries(-fsanitize=address)
Expand Down
3 changes: 3 additions & 0 deletions src/protobuf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ target_link_libraries(${PROJECT_NAME}
)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

# https://learn.microsoft.com/en-us/answers/questions/864574/enabling-address-sanitizer-results-in-error-lnk203
target_compile_definitions(${PROJECT_NAME} PUBLIC _DISABLE_VECTOR_ANNOTATION _DISABLE_STRING_ANNOTATION)

message("Diretório de construção atual: ${CMAKE_CURRENT_BINARY_DIR}")

if (MSVC AND BUILD_STATIC_LIBRARY)
Expand Down
4 changes: 1 addition & 3 deletions vcproj/canary.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -569,9 +569,6 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<Target Name="EnsureGeneratedDirectoryExists" BeforeTargets="ProtoCompile">
<MakeDir Directories="generated" />
</Target>
<PropertyGroup>
<RunProtoCompile>true</RunProtoCompile>
</PropertyGroup>
Expand All @@ -593,6 +590,7 @@
<ProtoFiles Include="$(ProtoPath)\*.proto" />
</ItemGroup>
<Target Name="ProtoCompile" BeforeTargets="PrepareForBuild" DependsOnTargets="VcpkgInstallManifestDependencies">
<MakeDir Directories="$(ProjectDir)generated" />
<Exec Command="$(ProtocPath) --proto_path=$(ProtoPath) --cpp_out=generated %(ProtoFiles.Identity)" />
<ItemGroup>
<ClCompile Include="generated\%(ProtoFiles.Filename).pb.cc">
Expand Down
Loading