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

Build failures with GCC11 and libstdc++11 #7918

Closed
ankurvdev opened this issue Jun 2, 2021 · 11 comments · Fixed by #7957
Closed

Build failures with GCC11 and libstdc++11 #7918

ankurvdev opened this issue Jun 2, 2021 · 11 comments · Fixed by #7957
Assignees
Labels
build build issues; typically submitted using template

Comments

@ankurvdev
Copy link
Contributor

Describe the bug
GoogleTest fails to compile with -Wno-maybe-uninitialized warning (elevated to error)

Urgency
Broken build

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Fedora 34
  • ONNX Runtime installed from (source or binary): Source
  • ONNX Runtime version:
  • Python version:
  • Visual Studio version (if applicable):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version:
  • GPU model and memory:

To Reproduce
Build on platforms with GCC11 and libstdc++11

Expected behavior
A clear and concise description of what you expected to happen.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
-Wno-maybe-uninitialized warning (elevated to error) while compiling googletest

@snnn
Copy link
Member

snnn commented Jun 2, 2021

#7893 will solve this.

@ankurvdev
Copy link
Contributor Author

I think we discussed this issue in an earlier build issue #7583 where it was agreed that we can update googletest to a newer version as a separate PR but we missed doing that.

I pushed a PR out now.

#7919

Moving to the latest googletest commit fixes the issue

@ankurvdev
Copy link
Contributor Author

From the description of #7893 it does not attempt to address the -Wno-maybe-uninitialized issue ( which seems to be new to gcc11)

A correct fix here would perhaps be to add this extra flag (I'm not sure where) to cflags if the compiler we detect is gcc>=11 (not sure how)

@snnn
Copy link
Member

snnn commented Jun 2, 2021

I disabled all the warnings for gmock. Can you help me try it again? If it still fails, please let me know which *.cc source file caused the error.

@snnn snnn self-assigned this Jun 2, 2021
@snnn snnn added the build build issues; typically submitted using template label Jun 2, 2021
@ankurvdev
Copy link
Contributor Author

@snnn

Looks like #7893 already merged
let me verify it locally

@ankurvdev
Copy link
Contributor Author

still there

onnxruntime.git/cmake/external/googletest/googletest/src/gtest-death-test.cc:1301:24

[57/1279] /usr/bin/c++ -DEIGEN_MPL2_ONLY -DENABLE_CPU_FP16_TRAINING_OPS -DENABLE_ORT_FORMAT_LOAD -I/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/include -I/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest -fPIC -ffunction-sections -fdata-sections -g -fPIC -Wall -Wshadow -Werror -Wno-error=dangling-else -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -std=c++11 -MD -MT external/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -MF external/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o.d -o external/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -c /home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/src/gtest-all.cc
FAILED: external/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
/usr/bin/c++ -DEIGEN_MPL2_ONLY -DENABLE_CPU_FP16_TRAINING_OPS -DENABLE_ORT_FORMAT_LOAD -I/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/include -I/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest -fPIC -ffunction-sections -fdata-sections -g -fPIC -Wall -Wshadow -Werror -Wno-error=dangling-else -DGTEST_HAS_PTHREAD=1 -fexceptions -Wextra -Wno-unused-parameter -Wno-missing-field-initializers -std=c++11 -MD -MT external/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -MF external/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o.d -o external/googletest/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o -c /home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/src/gtest-all.cc
In file included from /home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/src/gtest-all.cc:42:
/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/src/gtest-death-test.cc:1301:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1301 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/src/gtest-death-test.cc:1290:13: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
 1290 | static void StackLowerThanAddress(const void* ptr, bool* result) {
      |             ^~~~~~~~~~~~~~~~~~~~~
/home/ankurv/onnxruntime.git/cmake/external/googletest/googletest/src/gtest-death-test.cc:1299:7: note: ‘dummy’ declared here
 1299 |   int dummy;
      |       ^~~~~
cc1plus: all warnings being treated as errors

@snnn
Copy link
Member

snnn commented Jun 4, 2021

Ok, please duplicate this line https://github.com/microsoft/onnxruntime/blob/master/cmake/CMakeLists.txt#L610 and change gmock to gtest.

@ankurvdev
Copy link
Contributor Author

This works ! Thanks

@snnn
Copy link
Member

snnn commented Jun 5, 2021

You may submit a PR if you feel it is good.

@ankurvdev
Copy link
Contributor Author

Here you go #7957

@snnn snnn closed this as completed in #7957 Jun 7, 2021
@snnn
Copy link
Member

snnn commented Jun 8, 2021

#7984 as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build build issues; typically submitted using template
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants