https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108287
Bug ID: 108287
Summary: AVR build: gcc/config/avr/t-avr tries to edit the
source tree
Product: gcc
Version: 12.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: other
Assignee: unassigned at gcc dot gnu.org
Reporter: nicow.mattia at gmail dot com
Target Milestone: ---
This only occurs when building for target=avr.
As per the build instructions, I'm building GCC out of the source tree. The
configure call looks like this:
```
$src/configure \
--target=avr \
--prefix=$out \
...
```
Here, `$src` is a RO directory, and the build will eventually fail like this:
```
...
g++ -std=gnu++11
/nix/store/7m0zk6xl14rkgi420mxyl0klssf7dhnb-gcc-src-patched/gcc/config/avr/gen-avr-mmcu-texi.cc
-o gen-avr-mmcu-texi
./gen-avr-mmcu-texi >
/nix/store/7m0zk6xl14rkgi420mxyl0klssf7dhnb-gcc-src-patched/gcc/doc/avr-mmcu.texi
/bin/sh:
/nix/store/7m0zk6xl14rkgi420mxyl0klssf7dhnb-gcc-src-patched/gcc/doc/avr-mmcu.texi:
Permission denied
```
The culprit is `gcc/config/avr/t-avr` at line 94:
```
$(srcdir)/doc/avr-mmcu.texi: gen-avr-mmcu-texi$(build_exeext)
$(RUN_GEN) ./$< > $@
```
I'm currently using the following patch to work around the issue:
```
diff --git a/gcc/config/avr/t-avr b/gcc/config/avr/t-avr
index deadbeef..deadbeef 100644
--- a/gcc/config/avr/t-avr 2023-01-03 21:56:23
+++ b/gcc/config/avr/t-avr 2023-01-03 21:56:32
@@ -91,9 +91,6 @@
$(srcdir)/config/avr/avr-arch.h $(TM_H)
$(CXX_FOR_BUILD) $(CXXFLAGS_FOR_BUILD) $< -o $@ $(INCLUDES)
-$(srcdir)/doc/avr-mmcu.texi: gen-avr-mmcu-texi$(build_exeext)
- $(RUN_GEN) ./$< > $@
-
s-device-specs: gen-avr-mmcu-specs$(build_exeext)
rm -rf device-specs
mkdir device-specs && cd device-specs && $(RUN_GEN) ../$<
```