google / google/googletest

[Bug]: Fix build warnings and errors on LCC (eLbrus C/C++ compiler)

Open
#4,603 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
39.5k
Forks
10.9k
Avg merge
6d 13h
Merged PRs (30d)
1

Description

### Describe the issue

I have a machine based on CPU with e2k (Elbrus) architecture, and it is supplied with EDG-based LCC compiler, which is mainly compatible with GCC, but not exactly. Specifically, it has different warning causes and (as of version 1.25) does not support `__attribute__((optimize("no-optimize-sibling-calls")))` (the same as with NVC, which has a specific workaround in googletest's code). Due to this, googletest can't be built with LCC on this machine without warnings and errors, unless patched correspondingly. And even then, after running CTest, the `googletest-list-tests-unittest` test fails.

I expect the build of googletest be successful and warningless with LCC that can fix these issues), and all CTest tests to pass. I'm ready to submit a PR which does that, from [my fork of googletest](https://github.com/makise-homura/googletest/tree/lcc-support).

Instead, I see a lot of unexpected warnings of `-Wunused-variable`, `-Wunused-but-set-variable`, `-Wunused-function`, `-Wshadow` that don't exist on GCC@x86_64, and, if building with lcc-1.25, the following error:
```
lcc: "/srv/home/molchan_i/googletest-master/googletest/googletest/src/gtest.cc", line 1166: error: unrecognized argument to attribute "optimize"
```

### Steps to reproduce the problem

* Use the e2k-based machine with LCC compiler. If you don't have one, I can provide user-mode ssh access to it (welcome [here](https://elbrus.kurisa.ch/), the machine of a subject is `yukari`).
* Clone googletest repository: `git clone https://github.com/google/googletest`
* Configure the project: `mkdir build; cd build; cmake -DCMAKE_BUILD_TYPE=Release -Dgmock_build_tests=ON -Dgtest_build_samples=ON -Dgtest_build_tests=ON -DBUILD_SHARED_LIBS=ON ../googletest`
* Build it: `make -j32` (you may specify different number of processes).
* You'll find a lot of build warnings.
* Optionally, run `ctest -j32` after build: you'll find `googletest-list-tests-unittest` test to fail.

If you proceed with LCC 1.25, you can't build gmock and gtest tests successfully (there are a lot of errors like `no instance of overloaded function "testing::ElementsAreArray" matches the argument list`, and compiling `googletest-printers-test.cc` segfaults--it looks like a known bug that was fixed in LCC 1.26), so configure string may look like this:
cmake -DCMAKE_BUILD_TYPE=Release -Dgmock_build_tests=OFF -Dgtest_build_samples=ON -Dgtest_build_tests=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_C_COMPILER=lcc-1.25 -DCMAKE_CXX_COMPILER=l++-1.25 ../googletest`.

### What version of GoogleTest are you using?

I use current `main`, commit ff233bdd4cac0a0bf6e5cd45bda3406814cb2796.

### What operating system and version are you using?

My `/etc/os-release`:
```
/etc/os-release
PRETTY_NAME="Elbrus Linux 7.2"
NAME="Elbrus Linux"
VERSION_ID="7"
VERSION="7.2"
ID="elbrus"
HOME_URL="http://www.mcst.ru/"
SUPPORT_URL="http://www.mcst.ru/support/"
BUG_REPORT_URL="https://bugs.mcst.ru/"
```

### What compiler and version are you using?

* LCC 1.25.20 (version string: `lcc:1.25.20:Nov-17-2021:e2k-v4-linux gcc (GCC) 7.3.0 compatible`)
* LCC 1.26.22 (version string: `lcc:1.26.22:Jan-10-2024:e2k-v4-linux gcc (GCC) 9.3.0 compatible`)

### What build system are you using?

I use cmake version 3.28.0.

### Additional context

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported CMake build with LCC and inspect googletest/src/gtest.cc, the googletest-list-tests-unittest failure, and googletest-printers-test.cc. Compare the LCC-specific warnings and attribute error with the existing NVC workaround. Done means a warningless supported build and all applicable CTest tests passing.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp
Domain
build-system, compilers, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.