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

cpu/esp32: fix compilation issues with GCC 12.2 #19450

Merged

Conversation

gschorcht
Copy link
Contributor

@gschorcht gschorcht commented Apr 4, 2023

Contribution description

This PR provides the changes in cpu/esp32 and cpu/esp_common to fix the compilation issues with GCC v12.2. It is required as the first step in the preparation of the upgrade to ESP-IDF version 5.1.

Please note: Insead of fixing the ESP-IDF 4.4 code itself by a big bunch of patches to fix the compilation problems with GCC v12.2, it temporarily disables some warnings. The reason is that the ESP-IDF 5.1 requires GCC v12.2 and should be fixed for this compiler version by the vendor.

Testing procedure

Green CI

The change were already tested with all ESP-specific modules like esp_now, esp_wifi, esp_spi and esp_ble for all supported ESP platforms.

Issues/PRs references

Prerequisite for RIOT-OS/riotdocker#227
Fixes issue #19421

@github-actions github-actions bot added Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: pkg Area: External package ports Platform: ESP Platform: This PR/issue effects ESP-based platforms labels Apr 4, 2023
@gschorcht gschorcht changed the title cpu/esp32: fix compilation issue with GCC 12.2 cpu/esp32: fix compilation issues with GCC 12.2 Apr 4, 2023
@gschorcht gschorcht added State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels Apr 4, 2023
@gschorcht gschorcht force-pushed the cpu/esp32/fix_compilation_with_gcc_12_2 branch from d27423d to 9aa43db Compare April 4, 2023 15:07
@gschorcht gschorcht added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Apr 4, 2023
@riot-ci
Copy link

riot-ci commented Apr 4, 2023

Murdock results

✔️ PASSED

d8d9a9b cpu/esp32: disable warnings in ESP-IDF for gcc 12.2

Success Failures Total Runtime
6882 0 6882 08m:34s

Artifacts

@gschorcht
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Apr 4, 2023
@gschorcht
Copy link
Contributor Author

bors cancel

@gschorcht
Copy link
Contributor Author

bors try

@bors
Copy link
Contributor

bors bot commented Apr 4, 2023

try

Already running a review

@bors
Copy link
Contributor

bors bot commented Apr 4, 2023

try

Build failed:

@gschorcht
Copy link
Contributor Author

bors try

bors bot added a commit that referenced this pull request Apr 4, 2023
@bors
Copy link
Contributor

bors bot commented Apr 5, 2023

try

Build succeeded:

@gschorcht gschorcht removed the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Apr 5, 2023
@gschorcht gschorcht requested review from benpicco and maribu April 5, 2023 04:40
@gschorcht
Copy link
Contributor Author

gschorcht commented Apr 5, 2023

Finally it compiled and worked for me locally with gcc 12.2 and still compiled in Murdock with gcc 8.4.0. That is, it can be compiled with either gcc 8.4.0 or gcc 12.2. So it seems to be ready.

Copy link
Member

@maribu maribu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. One remark inline. If you say it is worth to go for -misa-spec-2.2 instead, please squash that right in. Otherwise this can go in as is.

Comment on lines 209 to 216
ifeq (12,$(shell command -v $(CC) > /dev/null && $(CC) -dumpversion | cut -d . -f 1))
RISCV_MARCH = rv32imc_zicsr
else
RISCV_MARCH = rv32imc
endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In makefiles/arch/riscv.inc.mk this is handled slightly differently: It adds -misa-spec=2.2, which is the latest ISA spec where zicsr wasn't an extension. This also fixes an issue when binutils and GCC support different ISA specs and e.g. GCC requires the zicsr with the default ISA, but the assembler fails when invoked with -march=rv32imc_zicsr.

But I guess with the toolchains more closely controlled in the ESP32 scenario, this is fine as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work with -misa-spec=2.2. So I reverted the change to use again -march=rv32imc together with -misa-spec=2.2.

@github-actions github-actions bot added Area: doc Area: Documentation Area: tools Area: Supplementary tools labels Apr 5, 2023
@maribu
Copy link
Member

maribu commented Apr 5, 2023

The static tests are not yet happy. Please squash at will

@gschorcht
Copy link
Contributor Author

Ah sorry, I pushed accidentally the branch with PR #19452 included that caused the static test error. I removed this commit.

@maribu
Copy link
Member

maribu commented Apr 8, 2023

I do still approve, but the check-commits hook insists on squashing

@gschorcht
Copy link
Contributor Author

I do still approve, but the check-commits hook insists on squashing

I just wanted to keep the latest changes visible.

@gschorcht
Copy link
Contributor Author

gschorcht commented Apr 12, 2023

@maribu I compared my changes with yours in PR #18719. Some of them are the same but a number of changes differ. A number of differences are caused by the cleanup in PR #19426, e.g, cpu/esp32/periph/adc.c vs. cpu/eps32/esp-id-api/adc.c. Some of your changes seem to make more sense, e.g., cpu/esp32/esp-idf/esp_idf_support.c.

Should we compare and discuss the differences again? For example, my cpu/esp32/Makefile.include includes the changes needed for ESP32-C3 while yours include CFLAGS += -D__DYNAMIC_REENT__.

Your PR also includes changes for ESP8266 I would like to get in to be able to upgrade to a newer GCC version.

@maribu
Copy link
Member

maribu commented Apr 12, 2023

Maybe the easiest would be if I just close #18719 in favor of this PR - I haven't really looked actively into or updated the PR for some time anyway. If there is something useful to scavenge from (e.g. regarding ESP8266), you are welcome to do so.

@@ -111,7 +111,7 @@ void IRAM_ATTR esp_log_writev(esp_log_level_t level,
* We use the log level set for the given tag instead of using
* the given log level.
*/
esp_log_level_t act_level = LOG_DEBUG;
esp_log_level_t act_level = (esp_log_level_t)LOG_DEBUG;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maribu I'm wondering what the cleaner approach would be here. Casting to RIOT's LOG_DEBUG to esp_log_level_t or using ESP_LOG_DEBUG as in PR #18532. the enumeration esp_log_level_t is compatible with RIOT's log levels.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is more a matter of personal taste an either is fine

@benpicco
Copy link
Contributor

bors merge

@bors
Copy link
Contributor

bors bot commented Apr 16, 2023

👎 Rejected by PR status

@gschorcht
Copy link
Contributor Author

Thanks for the try to merge it. I had to squash it before.

@gschorcht
Copy link
Contributor Author

borse merge

@maribu
Copy link
Member

maribu commented Apr 17, 2023

bors merge

@bors
Copy link
Contributor

bors bot commented Apr 17, 2023

👎 Rejected by PR status

@maribu
Copy link
Member

maribu commented Apr 17, 2023

Forgot to push the squash commits?

@gschorcht gschorcht force-pushed the cpu/esp32/fix_compilation_with_gcc_12_2 branch from cc1b56f to d8d9a9b Compare April 17, 2023 13:07
@gschorcht
Copy link
Contributor Author

Indeed.

@benpicco
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request Apr 17, 2023
19411: cpu/gd32v: add riotboot support r=benpicco a=gschorcht

### Contribution description

This PR provides `riotboot` support for GD32V.

### Testing procedure

Use any GD32V board with a JTAG adapter and flash the bootloader:
```python
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C bootloaders/riotboot flash
```
Flash slot 0 and set `RIOT_VERSION` to 1
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=1 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot0
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08001000
```
```python
> main(): This is RIOT! (Version: 1)
test_shell.
```
Flash slot 1 and set `RIOT_VERSION` to 2
```python
USEMODULE=stdio_uart FEATURES_REQUIRED=riotboot RIOT_VERSION=2 \
PROGRAMMER=openocd BOARD=sipeed-longan-nano make -C tests/shell riotboot/flash-slot1
...
### Flashing Target ###
Binfile detected, adding ROM base address: 0x08000000
Flashing with IMAGE_OFFSET: 0x08010800
```
```python
> main(): This is RIOT! (Version: 2)
test_shell.
```

### Issues/PRs references


19436: cpp11-compat: thread::sleep_for in microseconds r=benpicco a=kfessel

### Contribution description

after reviewing #19369  i found that there is a conversion to nanoseconds just to convert it to microseconds some instrunctions later for ztimer64_usec to handle it this removes one of the conversions (convert once direct to microseconds)

### Testing procedure

run the cpp tests

### Issues/PRs references

#19369

19450: cpu/esp32: fix compilation issues with GCC 12.2 r=benpicco a=gschorcht

### Contribution description

This PR provides the changes in `cpu/esp32` and `cpu/esp_common` to fix the compilation issues with GCC v12.2.  It is required as the first step in the preparation of the upgrade to ESP-IDF version 5.1.

**Please note**: Insead of fixing the ESP-IDF 4.4 code itself by a big bunch of patches to fix the compilation problems with GCC v12.2, it temporarily disables some warnings. The reason is that the ESP-IDF 5.1 requires GCC v12.2 and should be fixed for this compiler version by the vendor.

### Testing procedure

Green CI

The change were already tested with all ESP-specific modules like `esp_now`, `esp_wifi`, `esp_spi`  and `esp_ble` for all supported ESP platforms.

### Issues/PRs references

Prerequisite for RIOT-OS/riotdocker#227
Fixes issue #19421

19476: native/syscalls: rename real_clock_gettime to clock_gettime r=benpicco a=Teufelchen1

### Contribution description

When compiling RIOT for native using a recent LLVM and enabling ASAN, one might encounter "Duplicated symbol".

This is due to a name clash with `real_clock_gettime()` in compiler-rt from [LLVM](llvm/llvm-project@f50246d), I renamed RIOTs `real_clock_gettime` and just default to the posix function `clock_gettime`. The wrapper existed, most likely, for consistency only.

(The best solution would probably to convince the LLVM folks to declare their symbol as `static` and refactor a bit)

### Testing procedure

Passing CI should be enough.


Co-authored-by: Gunar Schorcht <[email protected]>
Co-authored-by: Karl Fessel <[email protected]>
Co-authored-by: Teufelchen1 <[email protected]>
@bors
Copy link
Contributor

bors bot commented Apr 17, 2023

Build failed (retrying...):

@bors
Copy link
Contributor

bors bot commented Apr 17, 2023

Build succeeded:

@bors bors bot merged commit 812c216 into RIOT-OS:master Apr 17, 2023
@gschorcht
Copy link
Contributor Author

gschorcht commented Apr 18, 2023

@maribu @benpicco Thanks for reviewing and merging.

@kaspar030 Next step would be to try to update Murdock RIOT-OS/riotdocker#227

bors bot added a commit that referenced this pull request May 9, 2023
19561: cpu/esp32: fix compilation issues with GCC 12.2 [backport 2023.04] r=MrKevinWeiss a=kaspar030

# Backport of #19450

### Contribution description

This PR provides the changes in `cpu/esp32` and `cpu/esp_common` to fix the compilation issues with GCC v12.2.  It is required as the first step in the preparation of the upgrade to ESP-IDF version 5.1.

**Please note**: Insead of fixing the ESP-IDF 4.4 code itself by a big bunch of patches to fix the compilation problems with GCC v12.2, it temporarily disables some warnings. The reason is that the ESP-IDF 5.1 requires GCC v12.2 and should be fixed for this compiler version by the vendor.

### Testing procedure

Green CI

The change were already tested with all ESP-specific modules like `esp_now`, `esp_wifi`, `esp_spi`  and `esp_ble` for all supported ESP platforms.

### Issues/PRs references

Prerequisite for RIOT-OS/riotdocker#227
Fixes issue #19421

Co-authored-by: Gunar Schorcht <[email protected]>
bors bot added a commit that referenced this pull request May 10, 2023
19561: cpu/esp32: fix compilation issues with GCC 12.2 [backport 2023.04] r=maribu a=kaspar030

# Backport of #19450

### Contribution description

This PR provides the changes in `cpu/esp32` and `cpu/esp_common` to fix the compilation issues with GCC v12.2.  It is required as the first step in the preparation of the upgrade to ESP-IDF version 5.1.

**Please note**: Insead of fixing the ESP-IDF 4.4 code itself by a big bunch of patches to fix the compilation problems with GCC v12.2, it temporarily disables some warnings. The reason is that the ESP-IDF 5.1 requires GCC v12.2 and should be fixed for this compiler version by the vendor.

### Testing procedure

Green CI

The change were already tested with all ESP-specific modules like `esp_now`, `esp_wifi`, `esp_spi`  and `esp_ble` for all supported ESP platforms.

### Issues/PRs references

Prerequisite for RIOT-OS/riotdocker#227
Fixes issue #19421

19563: treewide: fix typos and false positives found by codespell [backport 2023.04] r=maribu a=MrKevinWeiss

# Backport of #19528

### Contribution description

This fixes some typos and adds one correctly used abbreviation to the ignore list.



Co-authored-by: Gunar Schorcht <[email protected]>
Co-authored-by: Marian Buschsieweke <[email protected]>
bors bot added a commit to RIOT-OS/riotdocker that referenced this pull request May 10, 2023
227: riotbuild: bump esp32x toolchains to gcc version 12.2 r=kaspar030 a=gschorcht

This PR upgrades ESP32x toolchains to GCC version 12.2. Since ESP-IDF 5.1 requires this compiler version, this PR has to be merged before we can start with RIOT upgrade to ESP-IDF 5.1.

This PR depends on RIOT-OS/RIOT#19450.

Co-authored-by: Gunar Schorcht <[email protected]>
bors bot added a commit that referenced this pull request Aug 1, 2023
19452: dist/tools/esptools: upgrade ESP32x toolchains to GCC version 12.2 r=MrKevinWeiss a=gschorcht

### Contribution description

This PR upgrades ESP32x toolchains to GCC version 12.2 which is a prerequisite for upgrading the ESP-IDF to version 5.1.

This PR depends on PR #19450 

### Testing procedure

`dist/tools/install.sh all` should install all ESP32x toolchains.
`. dist/tools/export.sh all` should make them visible.

### Issues/PRs references

Depends on PR #19450 

Co-authored-by: Gunar Schorcht <[email protected]>
@benpicco benpicco added this to the Release 2023.07 milestone Aug 2, 2023
@gschorcht gschorcht deleted the cpu/esp32/fix_compilation_with_gcc_12_2 branch September 10, 2023 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: build system Area: Build system Area: cpu Area: CPU/MCU ports Area: pkg Area: External package ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ESP Platform: This PR/issue effects ESP-based platforms Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants