[Bug bootstrap/110550] libintl build without -fPIC even though --enable-shared is configured

2023-07-28 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110550

--- Comment #3 from Sascha Wilde  ---
Are there any additional tests i could provide to help resolving this issue?

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2023-07-24 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #30 from Sascha Wilde  ---
Anything else I should test?

[Bug bootstrap/110550] libintl build without -fPIC even though --enable-shared is configured

2023-07-14 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110550

--- Comment #2 from Sascha Wilde  ---
(please excuse my late reply)

Indeed without jit the build works as expected.

However, jit is the primary reason I'm building gcc on NetBSD.  
Building relocateable code also in the supporting libraries is essential 
for jit to work. (see also #100096 for reference)

[Bug other/110550] New: libintl build without -fPIC even though --enable-shared is configured

2023-07-04 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110550

Bug ID: 110550
   Summary: libintl build without -fPIC even though
--enable-shared is configured
   Product: gcc
   Version: 12.3.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: other
  Assignee: unassigned at gcc dot gnu.org
  Reporter: swi...@sha-bang.de
  Target Milestone: ---

This is kind of a sequel to #100096

Building on NetBSD 9.3 amd64

Configured with:
LDFLAGS="-L/usr/local/lib -R/usr/local/lib" ../gcc-12.3.0/configure \
  --enable-shared \
  --enable-host-shared \
  --enable-checking=release \
  --enable-languages=jit \
  --disable-multilib \
  --disable-libssp \
  --disable-lto \
  --disable-libquadmath \
  --disable-liboffloadmic \
  --disable-libada \
  --disable-libsanitizer \
  --disable-libquadmath-support \
  --disable-libgomp \
  --disable-libvtv \
  --disable-libsanitizer \
  --with-gmp=/usr/local \
  --with-mpc=/usr/local \
  --with-mpfr=/usr/local

building fails, because libintl.a is build without -fPIC:

/usr/bin/ld: ./../intl/libintl.a(bindtextdom.o): relocation R_X86_64_32 against
symbol `libintl_nl_default_dirname' can not be used when making a shared
object; recompile with -fPIC
/usr/bin/ld: ./../intl/libintl.a(loadmsgcat.o): relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: ./../intl/libintl.a(textdomain.o): relocation R_X86_64_32 against
symbol `libintl_nl_default_default_domain' can not be used when making a shared
object; recompile with -fPIC
/usr/bin/ld: ./../intl/libintl.a(dcigettext.o): relocation R_X86_64_32S against
`.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./../intl/libintl.a(plural-exp.o): relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: ./../intl/libintl.a(localcharset.o): relocation R_X86_64_32
against `.rodata.str1.1' can not be used when making a shared object; recompile
with -fPIC
/usr/bin/ld: ./../intl/libintl.a(localename.o): relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: ./../intl/libintl.a(log.o): relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: ./../intl/libintl.a(finddomain.o): relocation R_X86_64_32 against
`.bss' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: ./../intl/libintl.a(localealias.o): relocation R_X86_64_32 against
`.rodata.str1.1' can not be used when making a shared object; recompile with
-fPIC
/usr/bin/ld: ./../intl/libintl.a(plural.o): relocation R_X86_64_32S against
`.rodata' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: nonrepresentable section on output
collect2: error: ld returned 1 exit status
gmake[3]: *** [../../gcc-12.3.0/gcc/jit/Make-lang.in:168: libgccjit.so.0.0.1]
Error 1
gmake[3]: *** Waiting for unfinished jobs
rm gcc.pod
gmake[3]: Leaving directory '/home/wilde/src/gcc/gcc-12.3.0-build_noboot/gcc'
gmake[2]: *** [Makefile:5038: all-stage3-gcc] Error 2
gmake[2]: Leaving directory '/home/wilde/src/gcc/gcc-12.3.0-build_noboot'
gmake[1]: *** [Makefile:22605: stage3-bubble] Error 2
gmake[1]: Leaving directory '/home/wilde/src/gcc/gcc-12.3.0-build_noboot'
gmake: *** [Makefile:1067: all] Error 2

Strange enough, when manually entering the directory `intl` and
rebuilding the library simply by issuing `make clean ; make` it _will_
be build with -fPIC as expected.

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2022-06-27 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

Sascha Wilde  changed:

   What|Removed |Added

 Resolution|FIXED   |---
 Status|RESOLVED|UNCONFIRMED
Version|10.2.0  |12.1.0

--- Comment #29 from Sascha Wilde  ---
Unfortunately the problem is still not fully resolved.
When bootstrapping the compiler (tested with 12.1 on NetBSD 9.2) libintl is
still build without -fPIC, however, when manually rebuilding libintl it is
build
correctly without any changes to the Makefile:

gmake BOOT_CFLAGS='-O' -j2 bootstrap   # wrong result, due to libintl w/o -fPIC
cd intl
gmake -j2 clean
gmake -j2  # builds a sane libintl with -fPIC
cd ..
gmake BOOT_CFLAGS='-O' -j2  # now results in a woring compiler and libgccjit.so

No idea why that is, but it's fully reproachable...

[Bug bootstrap/105561] Nondeterministic ICE on creation of bits/stdc++.h.gch/O2g.gch and bits/extc++.h.gch/O2g.gch

2022-05-11 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105561

--- Comment #3 from Sascha Wilde  ---
(In reply to Richard Biener from comment #1)
> I wonder if you can get a backtrace from gdb for the crash?  When you add -v
> to the failing command you should see cc1plus being invoked, trace on that
> command.

Reading symbols from /home/wilde/src/gcc-12.1.0-build/./gcc/cc1plus...
run(gdb) run
Starting program: /home/wilde/src/gcc-12.1.0-build/gcc/cc1plus -quiet
-nostdinc++ -nostdinc++ -v -I
/home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2
-I
/home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include
-I /home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++ -iprefix
/home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/
-isystem /home/wilde/src/gcc-12.1.0-build/./gcc/include -isystem
/home/wilde/src/gcc-12.1.0-build/./gcc/include-fixed -isystem
/usr/local/i386-unknown-netbsdelf9.2/include -isystem
/usr/local/i386-unknown-netbsdelf9.2/sys-include
/home/wilde/src/gcc-12.1.0/libstdc++-v3/include/precompiled/stdc++.h -quiet
-dumpdir i386-unknown-netbsdelf9.2/bits/stdc++.h.gch/O2g.gch- -dumpbase
stdc++.h -dumpbase-ext .h -mtune=generic -march=i486 -g -g -O2 -O2 -version
-fchecking=1 -o /tmp//cccDHD3H.s --output-pch=
i386-unknown-netbsdelf9.2/bits/stdc++.h.gch/O2g.gch
GNU C++17 (GCC) version 12.1.0 (i386-unknown-netbsdelf9.2)
compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.0, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/local/i386-unknown-netbsdelf9.2/include"
ignoring nonexistent directory
"/usr/local/i386-unknown-netbsdelf9.2/sys-include"
ignoring nonexistent directory
"/home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include"
ignoring nonexistent directory
"/home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include-fixed"
ignoring nonexistent directory
"/home/wilde/src/gcc-12.1.0-build/gcc/../lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/../../../../i386-unknown-netbsdelf9.2/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory
"/usr/local/lib/gcc/i386-unknown-netbsdelf9.2/12.1.0/include-fixed"
ignoring nonexistent directory "/usr/local/i386-unknown-netbsdelf9.2/include"
#include "..." search starts here:
#include <...> search starts here:

/home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2

/home/wilde/src/gcc-12.1.0-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include
 /home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++
 /home/wilde/src/gcc-12.1.0-build/./gcc/include
 /home/wilde/src/gcc-12.1.0-build/./gcc/include-fixed
 /usr/include
End of search list.
GNU C++17 (GCC) version 12.1.0 (i386-unknown-netbsdelf9.2)
compiled by GNU C version 12.1.0, GMP version 6.2.1, MPFR version
4.1.0, MPC version 1.2.0, isl version isl-0.24-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: a1413fe37641e0518146e5d1b732cd59

Program received signal SIGBUS, Bus error.
0xb0cb4957 in __mmap () from /usr/lib/libc.so.12
(gdb) bt
#0  0xb0cb4957 in __mmap () from /usr/lib/libc.so.12
#1  0xb0cb1823 in mmap () from /usr/lib/libc.so.12
#2  0x08d7881d in netbsd_gt_pch_get_address (size=,
fd=) at ../../gcc-12.1.0/gcc/config/host-netbsd.cc:53
#3  0x086baf8d in gt_pch_save (f=) at
../../gcc-12.1.0/gcc/ggc-common.cc:529
#4  0x084d3030 in c_common_write_pch () at
../../gcc-12.1.0/gcc/c-family/c-pch.cc:175
#5  0x0832258d in c_parse_final_cleanups () at
../../gcc-12.1.0/gcc/cp/decl2.cc:5075
#6  0x084d2bf1 in c_common_parse_file () at
../../gcc-12.1.0/gcc/c-family/c-opts.cc:1262
#7  0x089bbc3e in compile_file () at ../../gcc-12.1.0/gcc/toplev.cc:452
#8  0x09a1fbf5 in do_compile (no_backend=) at
../../gcc-12.1.0/gcc/toplev.cc:2168
#9  toplev::main (this=, argc=, argv=)
at ../../gcc-12.1.0/gcc/toplev.cc:2320
#10 0x09a21b12 in main (argc=41, argv=0xbfb86ad0) at
../../gcc-12.1.0/gcc/main.cc:39
(gdb)

[Bug bootstrap/105561] Nondeterministic ICE on creation of bits/stdc++.h.gch/O2g.gch and bits/extc++.h.gch/O2g.gch

2022-05-11 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105561

--- Comment #2 from Sascha Wilde  ---
(In reply to Richard Biener from comment #1)
> I wonder if you can get a backtrace from gdb for the crash?  When you add -v
> to the failing command you should see cc1plus being invoked, trace on that
> command.
> 
> Does NetBSD have address space randomization?  That might influence whether
> the bug reproduces or not.

Yes NetBSD 9.2 has address space layout randomization active.

By "trace" you mean running the cc1plus command in gdb?

[Bug bootstrap/105561] New: Nondeterministic ICE on creation of bits/stdc++.h.gch/O2g.gch and bits/extc++.h.gch/O2g.gch

2022-05-11 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105561

Bug ID: 105561
   Summary: Nondeterministic ICE on creation of
bits/stdc++.h.gch/O2g.gch and
bits/extc++.h.gch/O2g.gch
   Product: gcc
   Version: 12.1.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: bootstrap
  Assignee: unassigned at gcc dot gnu.org
  Reporter: swi...@sha-bang.de
  Target Milestone: ---

I'm experiencing a strange, not deterministic ISE on creation of
bits/extc++.h.gch/O2g.gch and bits/stdc++.h.gch/O2g.gch during building
of gcc 12.1 on i386 NetBSD 9.2.

I know the following sounds like an hardware problem, but it certainly
is not, as it can be observed in the exactly same way on to totally
different hardwares:

1. A native system running NetBSD 9.2 (i386):
   Intel(R) Atom(TM) CPU N270   @ 1.60GHz
   2 GiB RAM

2. A virtual system running NetBSD 9.2 (i386):
   VirtualBox guest with
   11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
   16 GiB RAM (for the guest)

The symptoms are identical on both.

It happens during bootstraps well as during non boostrap compilation
with an already compiled gcc 12.1.

My configuration Options are:

../gcc-12.1.0/configure \
  --with-bugurl=https://github.com/jashandeep-sohi/libgccjit-pkg/issues \
  --enable-shared --enable-host-shared --enable-checking=release \
  --enable-languages=jit --disable-multilib --disable-libssp \
  --disable-lto --disable-libquadmath --disable-liboffloadmic \
  --disable-libada --disable-libsanitizer \
  --disable-libquadmath-support --disable-libgomp --disable-libvtv \
  --disable-libsanitizer --with-gmp=/usr/local --with-mpc=/usr/local \
  --with-mpfr=/usr/local 

Here is what happens (I'll choose bits/extc++.h.gch/O2g.gch as an
example, the exact same thing happens for bits/stdc++.h.gch/O2g.gch,
too):

The compilation fails like this:

8< --
[...]
/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc/xgcc
-shared-libgcc
-B/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc
-nostdinc++
-L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src
-L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/src/.libs
-L/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/libsupc++/.libs
-B/usr/local/i386-unknown-netbsdelf9.2/bin/
-B/usr/local/i386-unknown-netbsdelf9.2/lib/ -isystem
/usr/local/i386-unknown-netbsdelf9.2/include -isystem
/usr/local/i386-unknown-netbsdelf9.2/sys-include   -fno-checking -x c++-header
-nostdinc++ -g -O2 
-I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include/i386-unknown-netbsdelf9.2
-I/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include
-I/home/wilde/src/gcc-12.1.0/libstdc++-v3/libsupc++  -O2 -g
/home/wilde/src/gcc-12.1.0/libstdc++-v3/include/precompiled/extc++.h -o
i386-unknown-netbsdelf9.2/bits/extc++.h.gch/O2g.gch 
xgcc: internal compiler error: Segmentation fault signal terminated program
cc1plus
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
See  for instructions.
gmake[5]: *** [Makefile:1904:
i386-unknown-netbsdelf9.2/bits/extc++.h.gch/O2g.gch] Error 4
gmake[5]: Leaving directory
'/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include'
gmake[4]: *** [Makefile:576: all-recursive] Error 1
gmake[4]: Leaving directory
'/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3'
gmake[3]: *** [Makefile:501: all] Error 2
gmake[3]: Leaving directory
'/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3'
gmake[2]: *** [Makefile:17355: all-stage1-target-libstdc++-v3] Error 2
gmake[2]: Leaving directory
'/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build'
gmake[1]: *** [Makefile:22332: stage1-bubble] Error 2
gmake[1]: Leaving directory
'/home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build'
gmake: *** [Makefile:1067: all] Error 2
-

Then I try to compile the file by hand, which usually fails, too some
times, but eventually succeeds:

8< --
% cd
~/src/gcc-12.1.0-default-optimization-no-bootstrap-build/i386-unknown-netbsdelf9.2/libstdc++-v3/include
% /home/wilde/src/gcc-12.1.0-default-optimization-no-bootstrap-build/./gcc/xgcc
-shared-libgcc

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-16 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #19 from Sascha Wilde  ---
(In reply to Jakub Jelinek from comment #14)
> Though, DW_AT_producer lines don't really provide the filename and comp_dir,
> so guess what I need is better
> readelf -wi libgccjit.so.0 | grep -A4 DW_AT_producer | bzip2 -9
> output.

I now attached the requested output to the issue.

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-16 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #18 from Sascha Wilde  ---
Created attachment 50612
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50612=edit
Output of: readelf -wi libgccjit.so.0 | grep -A4 DW_AT_producer

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #17 from Sascha Wilde  ---
(In reply to David Malcolm from comment #16)
> (In reply to Sascha Wilde from comment #10)
> > (In reply to David Malcolm from comment #8)
> > > It would be good to know exactly where that error message is being 
> > > emitted.
> > > 
> > > If you add:
> > >   gcc_jit_context_set_logfile (ctxt, stderr, 0, 0);
> > > to the test code (e.g. immediately after the call to
> > > gcc_jit_context_acquire), libgccjit ought to spew out a copious amount of
> > > logging (see
> > > https://gcc.gnu.org/onlinedocs/jit/internals/index.html#example-of-log-file)
> > > 
> > > Can you attach the log you get please?
> > 
> > With security.pax.mprotect.global=1 it produces no extra output.
> > I'll attach the output produced when security.pax.mprotect.global is
> > disabled.
> 
> Thanks!  I was wondering if the error message was:
>   (a) due to a problem dynamically linking libgccjit into the process, or
>   (b) a later problem with linking the code that libgccjit generates into
> the process.
> 
> Given that there's no extra log output at all with the protection flag, it
> sounds like it's (a) - though you may run into a similar problem with (b)
> if/when (a) gets solved.

FWIW, the reason why I stumbled upon this problem is that I am testing
the native compiling GNU Emacs branch[0] on the NetBSD system.
(Which, by the way, can be build and works great once
security.pax.mprotect.global is disabled)

When security.pax.mprotect.global is enable the Emacs, linked with
libgccjit can not be started at all, failing with the same error as
the hello-world example.  So this matches your analysis that the
problem is triggered by dynamically linking libgccjit.

[0] https://akrl.sdf.org/gccemacs.html

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #15 from Sascha Wilde  ---
(In reply to Jakub Jelinek from comment #13)
> readelf -wi libgccjit.so.0 | grep DW_AT_producer | grep -v 'fPIC\|fpic'

FWIW, I had the command running for quite some while without spotting any
line not containing -fPIC -- but these might still come though...


(In reply to Jakub Jelinek from comment #14)
> Though, DW_AT_producer lines don't really provide the filename and comp_dir,
> so guess what I need is better
> readelf -wi libgccjit.so.0 | grep -A4 DW_AT_producer | bzip2 -9
> output.

Ill provide you with the output.  Please allow me some time, as this really 
runs _long_ on the system in question (a small Atom CPU N270).

I hope to provide the output tomorrow...

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #12 from Sascha Wilde  ---
(In reply to Jakub Jelinek from comment #9)
> Perhaps
> readelf -wi libgccjit.so.0 | grep DW_AT_producer
> would make it clearer on what is and what is not built with -fpic/-fPIC.

This runs quite long and only yields lines like:

   DW_AT_producer: (indirect string, offset: 0x155c1): GNU C++14
10.2.0 -mtune=generic -march=i486 -g -O2 -fPIC -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables
<30387>   DW_AT_producer: (indirect string, offset: 0x155c1): GNU C++14
10.2.0 -mtune=generic -march=i486 -g -O2 -fPIC -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables
<3ccf4>   DW_AT_producer: (indirect string, offset: 0x155c1): GNU C++14
10.2.0 -mtune=generic -march=i486 -g -O2 -fPIC -fno-exceptions -fno-rtti
-fasynchronous-unwind-tables

[...]

If this is really helpful to you, I'm fully willing to let it run through all 
the way and provide you with the complete output, of course.

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #11 from Sascha Wilde  ---
Created attachment 50603
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50603=edit
tut01-hello-world log output

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #10 from Sascha Wilde  ---
(In reply to David Malcolm from comment #8)
> It would be good to know exactly where that error message is being emitted.
> 
> If you add:
>   gcc_jit_context_set_logfile (ctxt, stderr, 0, 0);
> to the test code (e.g. immediately after the call to
> gcc_jit_context_acquire), libgccjit ought to spew out a copious amount of
> logging (see
> https://gcc.gnu.org/onlinedocs/jit/internals/index.html#example-of-log-file)
> 
> Can you attach the log you get please?

With security.pax.mprotect.global=1 it produces no extra output.
I'll attach the output produced when security.pax.mprotect.global is
disabled.

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #6 from Sascha Wilde  ---
However, please note that
"Cannot write-enable text segment: Permission denied"
is the more pressing problem, as it prevents libgccjit to be used
on NetBSD with default security settings.

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #5 from Sascha Wilde  ---
(In reply to Jakub Jelinek from comment #3)
> So, how many text relocations do you see?
> E.g. readelf -Wa libgccjit.so.0 output attached here would be useful.

I attached the requested output (its nearly 9MiB uncompressed, so used bzip2 
to stay below the file size limit of 1000K)

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #4 from Sascha Wilde  ---
Created attachment 50602
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50602=edit
Output of: readelf -Wa /usr/local/lib/libgccjit.so

[Bug jit/100096] libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

--- Comment #2 from Sascha Wilde  ---
> How did you build libgccjit.so.0?
> Have you used --enable-host-shared during configure?

Yes, AFAIK this is mandatory?

Here is the configuration I used:

../gcc-10.2.0/configure \
  --with-bugurl='https://github.com/jashandeep-sohi/libgccjit-pkg/issues' \
  --enable-shared \
  --enable-host-shared \
  --enable-checking=release \
  --enable-languages=jit \
  --disable-multilib \
  --disable-libssp \
  --disable-lto \
  --disable-libquadmath \
  --disable-liboffloadmic \
  --disable-libada \
  --disable-libsanitizer \
  --disable-libquadmath-support \
  --disable-libgomp \
  --disable-libvtv \
  --disable-libsanitizer \
  --with-gmp=/usr/local \
  --with-mpc=/usr/local \
  --with-mpfr=/usr/local

[Bug jit/100096] New: libgccjit.so.0: Cannot write-enable text segment: Permission denied on NetBSD 9.1

2021-04-15 Thread swilde--- via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100096

Bug ID: 100096
   Summary: libgccjit.so.0: Cannot write-enable text segment:
Permission denied on NetBSD 9.1
   Product: gcc
   Version: 10.2.0
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: jit
  Assignee: dmalcolm at gcc dot gnu.org
  Reporter: swi...@sha-bang.de
  Target Milestone: ---

On NetBSD 9.1 i386 the Hello World example from
https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html
fails with:

% ./tut01-hello-world
/usr/local/lib/libgccjit.so.0: text relocations
/usr/local/lib/libgccjit.so.0: Cannot write-enable text segment: Permission
denied

when security.pax.mprotect.global is enabled, which is the default on the
system.
When disabelin global memory protection (as root) with:

sysctl -w security.pax.mprotect.global=0

The example works (still emitting a warning:

% ./tut01-hello-world
/usr/local/lib/libgccjit.so.0: text relocations
hello world

Turning of security.pax.mprotect.global shouldn't be required for libgccjit
to work.

Also the warning "/usr/local/lib/libgccjit.so.0: text relocations" should
be prevented if possible.