-
Notifications
You must be signed in to change notification settings - Fork 12.4k
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
Add explicit symbol visibility macros to InstrProfData.inc #110732
Conversation
@llvm/pr-subscribers-pgo Author: Thomas Fransham (fsfod) ChangesAnnotating these symbols will fix missing symbols for InstrProfTest when using LLVM_BUILD_LLVM_DYLIB builds on windows. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window. Full diff: https://github.com/llvm/llvm-project/pull/110732.diff 2 Files Affected:
diff --git a/compiler-rt/include/profile/InstrProfData.inc b/compiler-rt/include/profile/InstrProfData.inc
index b9df3266fbcf8f..ea2903c92a5857 100644
--- a/compiler-rt/include/profile/InstrProfData.inc
+++ b/compiler-rt/include/profile/InstrProfData.inc
@@ -62,6 +62,15 @@
#define INSTR_PROF_VISIBILITY
#endif
+/* This is include is needed for symbol visibility macros used on
+ * ValueProfRecord\ValueProfData so there functions are exported from the
+ * LLVM shared library on windows. */
+#ifdef __cplusplus
+#include "llvm/Support/Compiler.h"
+#else
+#define LLVM_ABI
+#endif
+
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
// are readable (e.g., after `issue #82426` is fixed)
/* INSTR_PROF_DATA start. */
@@ -358,7 +367,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covname, \
* This is the header of the data structure that defines the on-disk
* layout of the value profile data of a particular kind for one function.
*/
-typedef struct ValueProfRecord {
+typedef struct LLVM_ABI ValueProfRecord {
/* The kind of the value profile record. */
uint32_t Kind;
/*
@@ -408,7 +417,7 @@ typedef struct ValueProfRecord {
* Per-function header/control data structure for value profiling
* data in indexed format.
*/
-typedef struct ValueProfData {
+typedef struct LLVM_ABI ValueProfData {
/*
* Total size in bytes including this field. It must be a multiple
* of sizeof(uint64_t).
diff --git a/llvm/include/llvm/ProfileData/InstrProfData.inc b/llvm/include/llvm/ProfileData/InstrProfData.inc
index b9df3266fbcf8f..ea2903c92a5857 100644
--- a/llvm/include/llvm/ProfileData/InstrProfData.inc
+++ b/llvm/include/llvm/ProfileData/InstrProfData.inc
@@ -62,6 +62,15 @@
#define INSTR_PROF_VISIBILITY
#endif
+/* This is include is needed for symbol visibility macros used on
+ * ValueProfRecord\ValueProfData so there functions are exported from the
+ * LLVM shared library on windows. */
+#ifdef __cplusplus
+#include "llvm/Support/Compiler.h"
+#else
+#define LLVM_ABI
+#endif
+
// clang-format off:consider re-enabling clang-format if auto-formatted C macros
// are readable (e.g., after `issue #82426` is fixed)
/* INSTR_PROF_DATA start. */
@@ -358,7 +367,7 @@ INSTR_PROF_SECT_ENTRY(IPSK_covname, \
* This is the header of the data structure that defines the on-disk
* layout of the value profile data of a particular kind for one function.
*/
-typedef struct ValueProfRecord {
+typedef struct LLVM_ABI ValueProfRecord {
/* The kind of the value profile record. */
uint32_t Kind;
/*
@@ -408,7 +417,7 @@ typedef struct ValueProfRecord {
* Per-function header/control data structure for value profiling
* data in indexed format.
*/
-typedef struct ValueProfData {
+typedef struct LLVM_ABI ValueProfData {
/*
* Total size in bytes including this field. It must be a multiple
* of sizeof(uint64_t).
|
@@ -62,6 +62,15 @@ | |||
#define INSTR_PROF_VISIBILITY | |||
#endif | |||
|
|||
/* This is include is needed for symbol visibility macros used on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"This is include" => "This include"
That said, we usually add the comment to the use site.
Can you attach a full log of the build failure without this patch? It should be included to the patch description/commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so the comment should be by both the classes annotated with the macro from that header instead?
I should add the build failure will need a lot more code merged to trigger, but i wanted to give some context to this change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the linker error:
llvm\lld-link : error : undefined symbol: public: static class std::unique_ptr<struct llvm::ValueProfData, struct std::default_delete<struct llvm::ValueProfData>> __cdecl llvm::ValueProfData::serializeFrom(struct llvm::InstrProfRecord const &)
>>> referenced by llvm\unittests\ProfileData\InstrProfTest.cpp:1368
>>> unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/InstrProfTest.cpp.obj:(private: virtual void __cdecl `anonymous namespace'::ValueProfileReadWriteTest_value_prof_data_read_write_Test::TestBody(void))
>>> referenced by llvm\unittests\ProfileData\InstrProfTest.cpp:1488
>>> unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/InstrProfTest.cpp.obj:(private: virtual void __cdecl `anonymous namespace'::ValueProfileReadWriteTest_symtab_mapping_Test::TestBody(void))
llvm\lld-link : error : undefined symbol: public: void __cdecl llvm::ValueProfData::deserializeTo(struct llvm::InstrProfRecord &, class llvm::InstrProfSymtab *)
>>> referenced by llvm\unittests\ProfileData\InstrProfTest.cpp:1372
>>> unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/InstrProfTest.cpp.obj:(private: virtual void __cdecl `anonymous namespace'::ValueProfileReadWriteTest_value_prof_data_read_write_Test::TestBody(void))
>>> referenced by llvm\unittests\ProfileData\InstrProfTest.cpp:1519
>>> unittests/ProfileData/CMakeFiles/ProfileDataTests.dir/InstrProfTest.cpp.obj:(private: virtual void __cdecl `anonymous namespace'::ValueProfileReadWriteTest_symtab_mapping_Test::TestBody(void))
a0d48fd
to
89a7368
Compare
89a7368
to
7236e20
Compare
Annotating these symbols will fix missing symbols for InstrProfTest when using shared library builds on windows with explicit visibility macros enabled. Add a empty fallback definition for LLVM_ABI macro so the code works in compiler-rt. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window. ``` llvm\lld-link : error : undefined symbol: public: void ValueProfData::deserializeTo(InstrProfRecord&, InstrProfSymtab*) >>> referenced by unittests\ProfileData\InstrProfTest.cpp:1372 void ValueProfileReadWriteTest_value_prof_data_read_write_Test::TestBody() ```
7236e20
to
dd56b78
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Let's move forward and reply on a post-commit reviews if necessary.
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/133/builds/5784 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/140/builds/9566 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/123/builds/8213 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/12891 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/159/builds/8945 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/30/builds/8986 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/11/builds/7220 Here is the relevant piece of the build log for the reference
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/56/builds/10766 Here is the relevant piece of the build log for the reference
|
Add explicit symbol visibility macros to InstrProfData.inc Annotating these symbols will fix missing symbols for InstrProfTest when using shared library builds on windows with explicit visibility macros enabled. Add a empty fallback definition for LLVM_ABI macro so the code works in compiler-rt. This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window. ``` llvm\lld-link : error : undefined symbol: public: void ValueProfData::deserializeTo(InstrProfRecord&, InstrProfSymtab*) >>> referenced by unittests\ProfileData\InstrProfTest.cpp:1372 void ValueProfileReadWriteTest_value_prof_data_read_write_Test::TestBody() ```
…lvm#110732)" This reverts commit d7ca703 in llvm#110732
Add explicit symbol visibility macros to InstrProfData.inc
Annotating these symbols will fix missing symbols for InstrProfTest when
using shared library builds on windows with explicit visibility macros enabled.
Add a empty fallback definition for LLVM_ABI macro so the code works in compiler-rt.
This is part of the work to enable LLVM_BUILD_LLVM_DYLIB and plugins on window.