-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix ODR issues around weak symbols for bundled runtime schema
Summary: This diff removes the default implementation for the weak symbol used for finding runtime schema information of transitively included Thrift files. If a thrift file is included in more than one file, then we have an ODR violation for the default implementation provided by the weak symbols. In practice, I have witnessed that this causes in some cases, for the default (empty) implementation returning `""` to be picked instead of the strongly linked symbol. The bug has manifested in weird ways such as different implementations being picked depending on which header files are `#include`-ed, even though they do not cause any changes in the transitively linked-to targets in BUCK. The fix is to only have forward declarations for the weak symbols with no definitions. This passes ODR since declarations are not definitions, and so we introduce a helper function to deal with the fact that the symbol can now be `nullptr`. Now, build are working again. Reviewed By: pranavtbhat Differential Revision: D65635942 fbshipit-source-id: 012e3942c7894c4a35d323a0ffb127dfcf16d23e
- Loading branch information
1 parent
afd9f62
commit 9964c10
Showing
6 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
third-party/thrift/src/thrift/lib/cpp2/gen/module_constants_cpp.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include <thrift/lib/cpp2/gen/module_constants_cpp.h> | ||
|
||
namespace apache::thrift::detail::mc { | ||
|
||
::std::string_view readSchema(::std::string_view (*access)()) { | ||
return access == nullptr ? ::std::string_view() : access(); | ||
} | ||
|
||
::std::string_view readSchemaInclude( | ||
::folly::Range<const ::std::string_view*> (*access)(), | ||
::std::size_t index) { | ||
return access == nullptr ? ::std::string_view() : access()[index]; | ||
} | ||
|
||
} // namespace apache::thrift::detail::mc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters