unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Building Emacs on WSL
@ 2016-12-11 17:42 Angelo Graziosi
  2016-12-16 15:05 ` Angelo Graziosi
  0 siblings, 1 reply; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-11 17:42 UTC (permalink / raw)
  To: Emacs developers

Just out of curiosity, I tried to build Emacs (master) on Windows 
Subsystem Linux (WSL) [*] but it always hangs at this point:

./autogen.sh

./configure --prefix=/opt/emacs --without-x
[...]
Configured for 'x86_64-unknown-linux-gnu'.

   Where should the build process find the source code?    .
   What compiler should emacs be built with?               gcc 
-std=gnu11 -g3 -O2
   Should Emacs use the GNU version of malloc?             yes
       (Using Doug Lea's new malloc from the GNU C Library.)
   Should Emacs use a relocating allocator for buffers?    no
   Should Emacs use mmap(2) for buffer allocation?         no
   What window system should Emacs use?                    none
   What toolkit should Emacs use?                          none
   Where do we find X Windows header files?                NONE
   Where do we find X Windows libraries?                   NONE
   Does Emacs use -lXaw3d?                                 no
   Does Emacs use -lXpm?                                   no
   Does Emacs use -ljpeg?                                  yes
   Does Emacs use -ltiff?                                  no
   Does Emacs use a gif library?                           no
   Does Emacs use a png library?                           no
   Does Emacs use -lrsvg-2?                                no
   Does Emacs use cairo?                                   no
   Does Emacs use imagemagick?                             no
   Does Emacs support sound?                               yes
   Does Emacs use -lgpm?                                   no
   Does Emacs use -ldbus?                                  no
   Does Emacs use -lgconf?                                 no
   Does Emacs use GSettings?                               no
   Does Emacs use a file notification library?             yes -lglibc 
(inotify)
   Does Emacs use access control lists?                    yes -lacl
   Does Emacs use -lselinux?                               no
   Does Emacs use -lgnutls?                                yes
   Does Emacs use -lxml2?                                  yes
   Does Emacs use -lfreetype?                              no
   Does Emacs use -lm17n-flt?                              no
   Does Emacs use -lotf?                                   no
   Does Emacs use -lxft?                                   no
   Does Emacs use -lsystemd?                               no
   Does Emacs directly use zlib?                           yes
   Does Emacs have dynamic modules support?                no
   Does Emacs use toolkit scroll bars?                     no
   Does Emacs support Xwidgets (requires gtk3)?            no
[...]

make
[...]
make -C ../lisp update-subdirs
make[2]: ingresso nella directory 
"/home/angelog/work/emacs-e63c489dd496e53b68b942d0b76e13b62117fae9/lisp"
make[2]: uscita dalla directory 
"/home/angelog/work/emacs-e63c489dd496e53b68b942d0b76e13b62117fae9/lisp"
./temacs --batch  --load loadup bootstrap

(I waited for almost an hour)

I tried with a master of a few days ago which surely build and works on 
GNU/Linux Mint 18, Windows (MSYS2/MinGW64) and macOS.

Just out of curiosity...

Ciao,
  Angelo.


----
[*] It seems that someone succeeded in that build 
(http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00339.html)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-11 17:42 Building Emacs on WSL Angelo Graziosi
@ 2016-12-16 15:05 ` Angelo Graziosi
  2016-12-16 15:30   ` Eli Zaretskii
  2016-12-20 12:20   ` Fabrice Popineau
  0 siblings, 2 replies; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-16 15:05 UTC (permalink / raw)
  To: Emacs developers

Just for the record...

I adopted the workaround suggested in etc/PROBLEMS (and from the WEB [*]):

   echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

and with it I was able to build,

./autogen.sh

CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe" LDFLAGS="-pipe" CC="gcc" 
./configure --prefix=/opt/emacs --build=x86_64-pc-linux-gnu --without-x 
--with-gnutls=no --disable-acl

make -j3


Emacs25 from the following source packages:

emacs-25.1.90.tar.gz
emacs-25.1.tar.gz
emacs-emacs-25.tar.gz (2016-12-11 10:50"17, 467768f64ee109fe)


BUT NOT emacs-master.tar.gz from master whose build always hangs as I 
described (./temacs --batch... see below)

At least, now I have an Emacs build (noX) working inside WSL!

Ciao,
Angelo.

-----
[*] 
http://stackoverflow.com/questions/38905344/windows-bash-emacs-build-fail-memory-protection-enabled

Il 11/12/2016 18:42, Angelo Graziosi ha scritto:
> Just out of curiosity, I tried to build Emacs (master) on Windows
> Subsystem Linux (WSL) [*] but it always hangs at this point:
>
> ./autogen.sh
>
> ./configure --prefix=/opt/emacs --without-x
> [...]
> Configured for 'x86_64-unknown-linux-gnu'.
>
>   Where should the build process find the source code?    .
>   What compiler should emacs be built with?               gcc -std=gnu11
> -g3 -O2
>   Should Emacs use the GNU version of malloc?             yes
>       (Using Doug Lea's new malloc from the GNU C Library.)
>   Should Emacs use a relocating allocator for buffers?    no
>   Should Emacs use mmap(2) for buffer allocation?         no
>   What window system should Emacs use?                    none
>   What toolkit should Emacs use?                          none
>   Where do we find X Windows header files?                NONE
>   Where do we find X Windows libraries?                   NONE
>   Does Emacs use -lXaw3d?                                 no
>   Does Emacs use -lXpm?                                   no
>   Does Emacs use -ljpeg?                                  yes
>   Does Emacs use -ltiff?                                  no
>   Does Emacs use a gif library?                           no
>   Does Emacs use a png library?                           no
>   Does Emacs use -lrsvg-2?                                no
>   Does Emacs use cairo?                                   no
>   Does Emacs use imagemagick?                             no
>   Does Emacs support sound?                               yes
>   Does Emacs use -lgpm?                                   no
>   Does Emacs use -ldbus?                                  no
>   Does Emacs use -lgconf?                                 no
>   Does Emacs use GSettings?                               no
>   Does Emacs use a file notification library?             yes -lglibc
> (inotify)
>   Does Emacs use access control lists?                    yes -lacl
>   Does Emacs use -lselinux?                               no
>   Does Emacs use -lgnutls?                                yes
>   Does Emacs use -lxml2?                                  yes
>   Does Emacs use -lfreetype?                              no
>   Does Emacs use -lm17n-flt?                              no
>   Does Emacs use -lotf?                                   no
>   Does Emacs use -lxft?                                   no
>   Does Emacs use -lsystemd?                               no
>   Does Emacs directly use zlib?                           yes
>   Does Emacs have dynamic modules support?                no
>   Does Emacs use toolkit scroll bars?                     no
>   Does Emacs support Xwidgets (requires gtk3)?            no
> [...]
>
> make
> [...]
> make -C ../lisp update-subdirs
> make[2]: ingresso nella directory
> "/home/angelog/work/emacs-e63c489dd496e53b68b942d0b76e13b62117fae9/lisp"
> make[2]: uscita dalla directory
> "/home/angelog/work/emacs-e63c489dd496e53b68b942d0b76e13b62117fae9/lisp"
> ./temacs --batch  --load loadup bootstrap
>
> (I waited for almost an hour)
>
> I tried with a master of a few days ago which surely build and works on
> GNU/Linux Mint 18, Windows (MSYS2/MinGW64) and macOS.
>
> Just out of curiosity...
>
> Ciao,
>  Angelo.
>
>
> ----
> [*] It seems that someone succeeded in that build
> (http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00339.html)



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-16 15:05 ` Angelo Graziosi
@ 2016-12-16 15:30   ` Eli Zaretskii
  2016-12-16 17:48     ` Paul Eggert
  2016-12-20 12:20   ` Fabrice Popineau
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2016-12-16 15:30 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: emacs-devel

> From: Angelo Graziosi <angelo.graziosi@alice.it>
> Date: Fri, 16 Dec 2016 16:05:04 +0100
> 
> BUT NOT emacs-master.tar.gz from master whose build always hangs as I 
> described (./temacs --batch... see below)

If you want this issue solved, please attach a debugger to temacs, and
post the backtrace, preferably after filing a bug report.

Thanks.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-16 15:30   ` Eli Zaretskii
@ 2016-12-16 17:48     ` Paul Eggert
  2016-12-16 21:05       ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Paul Eggert @ 2016-12-16 17:48 UTC (permalink / raw)
  To: Eli Zaretskii, Angelo Graziosi; +Cc: emacs-devel

Eli Zaretskii wrote:
> If you want this issue solved, please attach a debugger to temacs, and
> post the backtrace, preferably after filing a bug report.

I thought the goal was to get portable dumping working soon? If so, this problem 
with WSL ought to be low priority, as portable dumping will make this porting 
problem irrelevant.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-16 17:48     ` Paul Eggert
@ 2016-12-16 21:05       ` Eli Zaretskii
  2016-12-17  1:00         ` Angelo Graziosi
  0 siblings, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2016-12-16 21:05 UTC (permalink / raw)
  To: Paul Eggert; +Cc: emacs-devel, angelo.graziosi

> Cc: emacs-devel@gnu.org
> From: Paul Eggert <eggert@cs.ucla.edu>
> Date: Fri, 16 Dec 2016 09:48:35 -0800
> 
> Eli Zaretskii wrote:
> > If you want this issue solved, please attach a debugger to temacs, and
> > post the backtrace, preferably after filing a bug report.
> 
> I thought the goal was to get portable dumping working soon? If so, this problem 
> with WSL ought to be low priority, as portable dumping will make this porting 
> problem irrelevant.

We don't know yet what caused this problem.  And I don't think future
developments should prevent users from reporting bugs.  We can, of
course, decide not to fix this or that bug, but I don't think we
should tell users we don't want to hear about them.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-16 21:05       ` Eli Zaretskii
@ 2016-12-17  1:00         ` Angelo Graziosi
  2016-12-17  8:02           ` Eli Zaretskii
  2016-12-17 14:25           ` Eli Zaretskii
  0 siblings, 2 replies; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-17  1:00 UTC (permalink / raw)
  To: Eli Zaretskii, Paul Eggert; +Cc: emacs-devel

Hi BIGS...

Il 16/12/2016 22:05, Eli Zaretskii ha scritto:
>> Cc:
>> From: Paul Eggert
>> Date: Fri, 16 Dec 2016 09:48:35 -0800
>>
>> Eli Zaretskii wrote:
>>> If you want this issue solved, please attach a debugger to temacs, and
>>> post the backtrace, preferably after filing a bug report.
>>
>> I thought the goal was to get portable dumping working soon? If so, this problem
>> with WSL ought to be low priority, as portable dumping will make this porting
>> problem irrelevant.
>
> We don't know yet what caused this problem.  And I don't think future
> developments should prevent users from reporting bugs.  We can, of
> course, decide not to fix this or that bug, but I don't think we
> should tell users we don't want to hear about them.
>

I understand this is a low priority issue if it is... Remember that WSL 
is marked as "beta". I flagged this only for the record, just in case 
someone had a similar experience.

BTW, in my builds of emacs-25 branch I notice a more serious issue. 
After "M-x package-list-packages", in the Packages buffer I cannot type 
anything. If I do, I get, embedded in that buffer,

[1]+ Stopped

and the Bash prompt, as if I had typed C-z, and 'fg' seems partially 
resurrect Emacs, but it is unusable. I have to close WSL window. In 
short I cannot install packages from MELPA/ELPA with these builds.

This issue is absent if I install (in WSL) the Ubuntu package 
emacs24-nox with apt-get...

I did also a build of emacs-25 using more or less the same "configure" 
with which emacs24-nox is built in Ubuntu. But no good results.


Ciao,
  Angelo.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-17  1:00         ` Angelo Graziosi
@ 2016-12-17  8:02           ` Eli Zaretskii
  2016-12-17  8:33             ` Angelo Graziosi
  2016-12-17 14:25           ` Eli Zaretskii
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2016-12-17  8:02 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: eggert, emacs-devel

> From: Angelo Graziosi <angelo.graziosi@alice.it>
> Date: Sat, 17 Dec 2016 02:00:31 +0100
> Cc: emacs-devel@gnu.org
> 
> > We don't know yet what caused this problem.  And I don't think future
> > developments should prevent users from reporting bugs.  We can, of
> > course, decide not to fix this or that bug, but I don't think we
> > should tell users we don't want to hear about them.
> >
> 
> I understand this is a low priority issue if it is... Remember that WSL 
> is marked as "beta". I flagged this only for the record, just in case 
> someone had a similar experience.

IME, it is unwise to assign priority to a problem one doesn't have a
sufficient understanding of.  With just a few more details, as would
be revealed by the backtrace from the hang, we could have a much
better idea.  That is why I asked for that.  I myself have no access
to such a system, nor sufficient time to install it and try that.

(A good example of inadvertently ignoring huge problems until they
are pretty much upon us is the ralloc.c incident: I'm sure we had
quite a few bug reports related to that from users who switched to
"bleeding-edge" GNU/Linux systems, but we effectively ignored them as
not reproducible because the crucial evidence that ralloc.c is being
compiled in was never presented.  If we had known this soon enough, we
could have prevented the problems people had with Emacs 25.1.)

> BTW, in my builds of emacs-25 branch I notice a more serious issue. 
> After "M-x package-list-packages", in the Packages buffer I cannot type 
> anything. If I do, I get, embedded in that buffer,
> 
> [1]+ Stopped
> 
> and the Bash prompt, as if I had typed C-z, and 'fg' seems partially 
> resurrect Emacs, but it is unusable. I have to close WSL window. In 
> short I cannot install packages from MELPA/ELPA with these builds.
> 
> This issue is absent if I install (in WSL) the Ubuntu package 
> emacs24-nox with apt-get...

Please always report such problems as bugs, using report-emacs-bug.

Thanks.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-17  8:02           ` Eli Zaretskii
@ 2016-12-17  8:33             ` Angelo Graziosi
  2016-12-17 10:55               ` Eli Zaretskii
  0 siblings, 1 reply; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-17  8:33 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: eggert, emacs-devel



Il 17/12/2016 09:02, Eli Zaretskii ha scritto:
> better idea.  That is why I asked for that.  I myself have no access
> to such a system, nor sufficient time to install it and try that.

WSL (Windows Subsystem for Linux) is new in Windows 10 Pro 64 bit (even 
if something similar is in W7). One only have to enable it. The 
installation take only a few minutes (< 15, I think):

https://msdn.microsoft.com/it-it/commandline/wsl/install_guide
https://msdn.microsoft.com/it-it/commandline/wsl/faq

>> This issue is absent if I install (in WSL) the Ubuntu package
>> emacs24-nox with apt-get...
>
> Please always report such problems as bugs, using report-emacs-bug.

Yes, let me to play with it a bit...

Ciao,
Angelo.




^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-17  8:33             ` Angelo Graziosi
@ 2016-12-17 10:55               ` Eli Zaretskii
  0 siblings, 0 replies; 25+ messages in thread
From: Eli Zaretskii @ 2016-12-17 10:55 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: eggert, emacs-devel

> Cc: eggert@cs.ucla.edu, emacs-devel@gnu.org
> From: Angelo Graziosi <angelo.graziosi@alice.it>
> Date: Sat, 17 Dec 2016 09:33:18 +0100
> 
> Il 17/12/2016 09:02, Eli Zaretskii ha scritto:
> > better idea.  That is why I asked for that.  I myself have no access
> > to such a system, nor sufficient time to install it and try that.
> 
> WSL (Windows Subsystem for Linux) is new in Windows 10 Pro 64 bit (even 
> if something similar is in W7). One only have to enable it. The 
> installation take only a few minutes (< 15, I think):
> 
> https://msdn.microsoft.com/it-it/commandline/wsl/install_guide
> https://msdn.microsoft.com/it-it/commandline/wsl/faq

Yes, I know.  Like I said: I have no access to such a system.

> >> This issue is absent if I install (in WSL) the Ubuntu package
> >> emacs24-nox with apt-get...
> >
> > Please always report such problems as bugs, using report-emacs-bug.
> 
> Yes, let me to play with it a bit...

Thanks.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-17  1:00         ` Angelo Graziosi
  2016-12-17  8:02           ` Eli Zaretskii
@ 2016-12-17 14:25           ` Eli Zaretskii
  2016-12-17 15:46             ` Angelo Graziosi
  1 sibling, 1 reply; 25+ messages in thread
From: Eli Zaretskii @ 2016-12-17 14:25 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: eggert, emacs-devel

> Cc: emacs-devel@gnu.org
> From: Angelo Graziosi <angelo.graziosi@alice.it>
> Date: Sat, 17 Dec 2016 02:00:31 +0100
> 
> BTW, in my builds of emacs-25 branch I notice a more serious issue. 
> After "M-x package-list-packages", in the Packages buffer I cannot type 
> anything. If I do, I get, embedded in that buffer,
> 
> [1]+ Stopped
> 
> and the Bash prompt, as if I had typed C-z, and 'fg' seems partially 
> resurrect Emacs, but it is unusable. I have to close WSL window. In 
> short I cannot install packages from MELPA/ELPA with these builds.

FWIW, I cannot reproduce this on this system:

  Linux fencepost.gnu.org 3.13.0-100-generic #147+7.0trisquel2 SMP Thu Oct 20 10:28:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-17 14:25           ` Eli Zaretskii
@ 2016-12-17 15:46             ` Angelo Graziosi
  0 siblings, 0 replies; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-17 15:46 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: eggert, emacs-devel



Il 17/12/2016 15:25, Eli Zaretskii ha scritto:
>> Cc: emacs-devel@gnu.org
>> From: Angelo Graziosi <angelo.graziosi@alice.it>
>> Date: Sat, 17 Dec 2016 02:00:31 +0100
>>
>> BTW, in my builds of emacs-25 branch I notice a more serious issue.
>> After "M-x package-list-packages", in the Packages buffer I cannot type
>> anything. If I do, I get, embedded in that buffer,
>>
>> [1]+ Stopped
>>
>> and the Bash prompt, as if I had typed C-z, and 'fg' seems partially
>> resurrect Emacs, but it is unusable. I have to close WSL window. In
>> short I cannot install packages from MELPA/ELPA with these builds.
>
> FWIW, I cannot reproduce this on this system:
>
>   Linux fencepost.gnu.org 3.13.0-100-generic #147+7.0trisquel2 SMP Thu Oct 20 10:28:26 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
>

Me too on GNU/Linux Mint 18 and macOS nor on MSYS2/MinGW64 or MSYS2 
(which has an Emacs package too). It seems WSL related but affects only 
emacs-25 branch.

WSL installs Ubuntu 14.04 [*] and installing the full emacs24 package 
does not show the issue (notice that also the full package, a GTK3 
build, starts in terminal mode, no GUI).

Ciao,
  Angelo.

-----
[*] It seems we should wait for Win10 build 14936 for Ubuntu 16.04.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-16 15:05 ` Angelo Graziosi
  2016-12-16 15:30   ` Eli Zaretskii
@ 2016-12-20 12:20   ` Fabrice Popineau
  2016-12-20 12:40     ` Fabrice Popineau
  2016-12-20 21:19     ` Angelo Graziosi
  1 sibling, 2 replies; 25+ messages in thread
From: Fabrice Popineau @ 2016-12-20 12:20 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 6540 bytes --]

For the record,

Emacs 25.1 builds fine and runs fine under WSL providing you install all
the required packages.
I used :
 ../emacs/configure --with-jpeg --with-xpm --with-tiff --with-rsvg
--with-xml2 --with-gnutls --with-imagemagick --with-png=yes
and mobaxterm as an X server. Everything is ok. I could even load Spacemacs
with its about 100 packages.

Emacs master fails with the same configuration. It fails bootstrapping:

(gdb) run  --batch  --load loadup bootstrap
Starting program: /mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs --batch
 --load loadup bootstrap
warning: Error disabling address space randomization: Succès
warning: linux_ptrace_test_ret_to_nx: PTRACE_KILL waitpid returned -1:
Appel système interrompu
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 17622 is executing new program:
/mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 17622 is executing new program:
/mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 17622 is executing new program:
/mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
process 17622 is executing new program:
/mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs

I must admit that I don't know how to read what gdb is reporting.

Fabrice

2016-12-16 16:05 GMT+01:00 Angelo Graziosi <angelo.graziosi@alice.it>:

> Just for the record...
>
> I adopted the workaround suggested in etc/PROBLEMS (and from the WEB [*]):
>
>   echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
>
> and with it I was able to build,
>
> ./autogen.sh
>
> CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe" LDFLAGS="-pipe" CC="gcc"
> ./configure --prefix=/opt/emacs --build=x86_64-pc-linux-gnu --without-x
> --with-gnutls=no --disable-acl
>
> make -j3
>
>
> Emacs25 from the following source packages:
>
> emacs-25.1.90.tar.gz
> emacs-25.1.tar.gz
> emacs-emacs-25.tar.gz (2016-12-11 10:50"17, 467768f64ee109fe)
>
>
> BUT NOT emacs-master.tar.gz from master whose build always hangs as I
> described (./temacs --batch... see below)
>
> At least, now I have an Emacs build (noX) working inside WSL!
>
> Ciao,
> Angelo.
>
> -----
> [*] http://stackoverflow.com/questions/38905344/windows-bash-
> emacs-build-fail-memory-protection-enabled
>
>
> Il 11/12/2016 18:42, Angelo Graziosi ha scritto:
>
>> Just out of curiosity, I tried to build Emacs (master) on Windows
>> Subsystem Linux (WSL) [*] but it always hangs at this point:
>>
>> ./autogen.sh
>>
>> ./configure --prefix=/opt/emacs --without-x
>> [...]
>> Configured for 'x86_64-unknown-linux-gnu'.
>>
>>   Where should the build process find the source code?    .
>>   What compiler should emacs be built with?               gcc -std=gnu11
>> -g3 -O2
>>   Should Emacs use the GNU version of malloc?             yes
>>       (Using Doug Lea's new malloc from the GNU C Library.)
>>   Should Emacs use a relocating allocator for buffers?    no
>>   Should Emacs use mmap(2) for buffer allocation?         no
>>   What window system should Emacs use?                    none
>>   What toolkit should Emacs use?                          none
>>   Where do we find X Windows header files?                NONE
>>   Where do we find X Windows libraries?                   NONE
>>   Does Emacs use -lXaw3d?                                 no
>>   Does Emacs use -lXpm?                                   no
>>   Does Emacs use -ljpeg?                                  yes
>>   Does Emacs use -ltiff?                                  no
>>   Does Emacs use a gif library?                           no
>>   Does Emacs use a png library?                           no
>>   Does Emacs use -lrsvg-2?                                no
>>   Does Emacs use cairo?                                   no
>>   Does Emacs use imagemagick?                             no
>>   Does Emacs support sound?                               yes
>>   Does Emacs use -lgpm?                                   no
>>   Does Emacs use -ldbus?                                  no
>>   Does Emacs use -lgconf?                                 no
>>   Does Emacs use GSettings?                               no
>>   Does Emacs use a file notification library?             yes -lglibc
>> (inotify)
>>   Does Emacs use access control lists?                    yes -lacl
>>   Does Emacs use -lselinux?                               no
>>   Does Emacs use -lgnutls?                                yes
>>   Does Emacs use -lxml2?                                  yes
>>   Does Emacs use -lfreetype?                              no
>>   Does Emacs use -lm17n-flt?                              no
>>   Does Emacs use -lotf?                                   no
>>   Does Emacs use -lxft?                                   no
>>   Does Emacs use -lsystemd?                               no
>>   Does Emacs directly use zlib?                           yes
>>   Does Emacs have dynamic modules support?                no
>>   Does Emacs use toolkit scroll bars?                     no
>>   Does Emacs support Xwidgets (requires gtk3)?            no
>> [...]
>>
>> make
>> [...]
>> make -C ../lisp update-subdirs
>> make[2]: ingresso nella directory
>> "/home/angelog/work/emacs-e63c489dd496e53b68b942d0b76e13b62117fae9/lisp"
>> make[2]: uscita dalla directory
>> "/home/angelog/work/emacs-e63c489dd496e53b68b942d0b76e13b62117fae9/lisp"
>> ./temacs --batch  --load loadup bootstrap
>>
>> (I waited for almost an hour)
>>
>> I tried with a master of a few days ago which surely build and works on
>> GNU/Linux Mint 18, Windows (MSYS2/MinGW64) and macOS.
>>
>> Just out of curiosity...
>>
>> Ciao,
>>  Angelo.
>>
>>
>> ----
>> [*] It seems that someone succeeded in that build
>> (http://lists.gnu.org/archive/html/emacs-devel/2016-12/msg00339.html)
>>
>
>


-- 
Fabrice Popineau
-----------------------------
CentraleSupelec
Département Informatique
3, rue Joliot Curie
91192 Gif/Yvette Cedex
Tel direct : +33 (0) 169851950
Standard : +33 (0) 169851212
------------------------------

[-- Attachment #2: Type: text/html, Size: 8927 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 12:20   ` Fabrice Popineau
@ 2016-12-20 12:40     ` Fabrice Popineau
  2016-12-20 19:35       ` Paul Eggert
  2016-12-21  9:00       ` Angelo Graziosi
  2016-12-20 21:19     ` Angelo Graziosi
  1 sibling, 2 replies; 25+ messages in thread
From: Fabrice Popineau @ 2016-12-20 12:40 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 2026 bytes --]

>
>
> Emacs master fails with the same configuration. It fails bootstrapping:
>
> (gdb) run  --batch  --load loadup bootstrap
> Starting program: /mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs
> --batch  --load loadup bootstrap
> warning: Error disabling address space randomization: Succès
> warning: linux_ptrace_test_ret_to_nx: PTRACE_KILL waitpid returned -1:
> Appel système interrompu
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> process 17622 is executing new program: /mnt/d/Source/emacs/build-
> emacs-ubuntu/src/temacs
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> process 17622 is executing new program: /mnt/d/Source/emacs/build-
> emacs-ubuntu/src/temacs
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> process 17622 is executing new program: /mnt/d/Source/emacs/build-
> emacs-ubuntu/src/temacs
> [Thread debugging using libthread_db enabled]
> Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
> process 17622 is executing new program: /mnt/d/Source/emacs/build-
> emacs-ubuntu/src/temacs
>
> I must admit that I don't know how to read what gdb is reporting.
>
>
However, there is a simple fix:

diff --git a/src/emacs.c b/src/emacs.c
index dc13b15..46a0593 100644
--- a/src/emacs.c
+++ b/src/emacs.c
@@ -699,6 +699,7 @@ main (int argc, char **argv)
   bool disable_aslr = dumping;
 # endif

+#if 0
   if (disable_aslr && disable_address_randomization ())
     {
       /* Set this so the personality will be reverted before execs
@@ -712,6 +713,7 @@ main (int argc, char **argv)
       /* If the exec fails, warn and then try anyway.  */
       perror (argv[0]);
     }
+#endif

 #ifndef CANNOT_DUMP
   might_dump = !initialized;

Now, Spacemacs loads as well with master.

Fabrice

[-- Attachment #2: Type: text/html, Size: 2823 bytes --]

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 12:40     ` Fabrice Popineau
@ 2016-12-20 19:35       ` Paul Eggert
  2016-12-20 20:03         ` Fabrice Popineau
  2016-12-20 20:57         ` Angelo Graziosi
  2016-12-21  9:00       ` Angelo Graziosi
  1 sibling, 2 replies; 25+ messages in thread
From: Paul Eggert @ 2016-12-20 19:35 UTC (permalink / raw)
  To: Fabrice Popineau, Angelo Graziosi; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1665 bytes --]

On 12/20/2016 04:40 AM, Fabrice Popineau wrote:
>
> (gdb) run  --batch  --load loadup bootstrap
> Starting program: /mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs 
> --batch  --load loadup bootstrap
> warning: Error disabling address space randomization: Succès

This is a warning from GDB, not from Emacs. GDB normally attempts to 
disable ASLR, to make debugging easier. Looking at the sequence of 
system calls in GDB 7.12, GDB calls 'personality' in some funky and 
undocumented ways, e.g., GDB assumes that errno is not changed when 
'personality' succeeds.

Please compile and run the attached program under WSL, using the same 
flags you use to compile Emacs, and let me know what it does. On Fedora 
24 x86-64, this program outputs:

personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully

When run under GDB, the same program outputs:

personality (0xffffffff) returns 0x40000, errno=0 (Success)
ADDR_NO_RANDOMIZE was set

because GDB already disabled ASLR. You can look at GDB's file 
gdb/nat/linux-personality.c to see how GDB differs from Emacs in this 
area; perhaps there's something there that Emacs can use to figure out 
that it is running with a buggy kernel.

>
> there is a simple fix:

That fix cannot be installed as-is since ASLR needs to be disabled on 
ordinary GNU/Linux platforms. It appears that WSL pretends to support 
the Linux 'personality' system call and its ADDR_NO_RANDOMIZE flag, and 
that this support does not actually work and makes Emacs crash.


[-- Attachment #2: personality.c --]
[-- Type: text/plain, Size: 834 bytes --]

#include <sys/personality.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

static int
print_personality (unsigned long persona, char const *msg)
{
  int pers, err;
  errno = 0;
  pers = personality (persona);
  err = errno;
  printf ("personality (%s) returns 0x%x, errno=%d (%s)\n",
	  msg, pers, err, strerror (err));
  errno = err;
  return pers;
}

int
main (void)
{
  int pers;
  pers = print_personality (0xffffffff, "0xffffffff");
  if (pers & ADDR_NO_RANDOMIZE)
    printf ("ADDR_NO_RANDOMIZE was set\n");
  else
    {
      printf ("ADDR_NO_RANDOMIZE was clear\n");
      pers = print_personality (pers | ADDR_NO_RANDOMIZE,
				"pers | ADDR_NO_RANDOMIZE");
      if (0 <= personality)
	printf ("ADDR_NO_RANDOMIZE set successfully");
      else
	printf ("ADDR_NO_RANDOMIZE could not be set");
    }
  return 0;
}

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 19:35       ` Paul Eggert
@ 2016-12-20 20:03         ` Fabrice Popineau
  2016-12-20 23:59           ` Angelo Graziosi
  2016-12-21  3:20           ` Paul Eggert
  2016-12-20 20:57         ` Angelo Graziosi
  1 sibling, 2 replies; 25+ messages in thread
From: Fabrice Popineau @ 2016-12-20 20:03 UTC (permalink / raw)
  To: Paul Eggert; +Cc: Emacs developers, Angelo Graziosi

[-- Attachment #1: Type: text/plain, Size: 4381 bytes --]

Thanks Paul for taking care of this.


2016-12-20 20:35 GMT+01:00 Paul Eggert <eggert@cs.ucla.edu>:

> On 12/20/2016 04:40 AM, Fabrice Popineau wrote:
>
>>
>> (gdb) run  --batch  --load loadup bootstrap
>> Starting program: /mnt/d/Source/emacs/build-emacs-ubuntu/src/temacs
>> --batch  --load loadup bootstrap
>> warning: Error disabling address space randomization: Succès
>>
>
> This is a warning from GDB, not from Emacs. GDB normally attempts to
> disable ASLR, to make debugging easier. Looking at the sequence of system
> calls in GDB 7.12, GDB calls 'personality' in some funky and undocumented
> ways, e.g., GDB assumes that errno is not changed when 'personality'
> succeeds.
>
> Please compile and run the attached program under WSL, using the same
> flags you use to compile Emacs, and let me know what it does. On Fedora 24
> x86-64, this program outputs:
>
> personality (0xffffffff) returns 0x0, errno=0 (Success)
> ADDR_NO_RANDOMIZE was clear
> personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
> ADDR_NO_RANDOMIZE set successfully
>
>
I get the very same result here :

fabrice@LOBSANG:/tmp$ ./personality
personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully
fabrice@LOBSANG:/tmp$

When run under GDB, the same program outputs:
>
> personality (0xffffffff) returns 0x40000, errno=0 (Success)
> ADDR_NO_RANDOMIZE was set
>
> because GDB already disabled ASLR. You can look at GDB's file
> gdb/nat/linux-personality.c to see how GDB differs from Emacs in this area;
> perhaps there's something there that Emacs can use to figure out that it is
> running with a buggy kernel.
>
> It seems it does not run the same way here:

fabrice@LOBSANG:/tmp$ gdb personality
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from personality...done.
(gdb) run
Starting program: /tmp/personality
warning: Error disabling address space randomization: Succès
warning: linux_ptrace_test_ret_to_nx: PTRACE_KILL waitpid returned -1:
Appel système interrompu
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully[Inferior 1 (process 19137) exited
normally]


>> there is a simple fix:
>>
>
> That fix cannot be installed as-is since ASLR needs to be disabled on
> ordinary GNU/Linux platforms. It appears that WSL pretends to support the
> Linux 'personality' system call and its ADDR_NO_RANDOMIZE flag, and that
> this support does not actually work and makes Emacs crash.
>

That looks like it.
I surely don't expect my "fix" to be included in master.
It is only a quick way to make emacs master run under WSL for those who
want to test it.
WSL (IMHO) is still a work in progress.
Once Ubuntu 16.04 will be available, maybe we should consider it more
seriously.
And even with 16.04, I wonder if it can compete with MSYS2/MinGW64.
It needs to be rock solid for that.
I am worried by the fact that neither SBCL nor CCL (Common Lisp) run under
WSL
and for a reason that maybe related to the same topic.

Regards,

Fabrice


-- 
Fabrice Popineau
-----------------------------
CentraleSupelec
Département Informatique
3, rue Joliot Curie
91192 Gif/Yvette Cedex
Tel direct : +33 (0) 169851950
Standard : +33 (0) 169851212
------------------------------

[-- Attachment #2: Type: text/html, Size: 6570 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 19:35       ` Paul Eggert
  2016-12-20 20:03         ` Fabrice Popineau
@ 2016-12-20 20:57         ` Angelo Graziosi
  1 sibling, 0 replies; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-20 20:57 UTC (permalink / raw)
  To: Paul Eggert, Fabrice Popineau; +Cc: Emacs developers



Il 20/12/2016 20:35, Paul Eggert ha scritto:
> Please compile and run the attached program under WSL, using the same
> flags you use to compile Emacs, and let me know what it does. On Fedora
> 24 x86-64, this program outputs:
>
> personality (0xffffffff) returns 0x0, errno=0 (Success)
> ADDR_NO_RANDOMIZE was clear
> personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
> ADDR_NO_RANDOMIZE set successfully
>
> When run under GDB, the same program outputs:
>
> personality (0xffffffff) returns 0x40000, errno=0 (Success)
> ADDR_NO_RANDOMIZE was set
>
> because GDB already disabled ASLR. You can look at GDB's file
> gdb/nat/linux-personality.c to see how GDB differs from Emacs in this
> area; perhaps there's something there that Emacs can use to figure out
> that it is running with a buggy kernel.

I did this:

$ gcc -std=gnu11 -g3 -O2 personality.c -o personality

(the command line set when Emacs is configured with "./configure 
--prefix=/opt/emacs --without-x")

$ ./personality
personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully

I rarely have used GDB (last time about ten years ago) and so I did:

$ gdb ./personality
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
[...]
(gdb) run
Starting program: /home/angelog/work/ports-packages/emacs/personality
warning: Error disabling address space randomization: Successo
warning: linux_ptrace_test_ret_to_nx: PTRACE_KILL waitpid returned -1: 
Chiamata di sistema interrotta
personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully[Inferior 1 (process 458) exited normally]
(gdb) q


which looks a bit different from yours..

Maybe you have a better way to use GDB...

Ciao,
  Angelo.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 12:20   ` Fabrice Popineau
  2016-12-20 12:40     ` Fabrice Popineau
@ 2016-12-20 21:19     ` Angelo Graziosi
  2016-12-20 22:01       ` Fabrice Popineau
  1 sibling, 1 reply; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-20 21:19 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: Emacs developers



Il 20/12/2016 13:20, Fabrice Popineau ha scritto:
> For the record,
>
> Emacs 25.1 builds fine and runs fine under WSL providing you install all
> the required packages.
> I used :
>  ../emacs/configure --with-jpeg --with-xpm --with-tiff --with-rsvg
> --with-xml2 --with-gnutls --with-imagemagick --with-png=yes
> and mobaxterm as an X server. Everything is ok. I could even load Spacemacs
> with its about 100 packages.
>

Yes, emacs-25 branch builds (adopting the work around 'echo 0 | sudo tee 
/proc/sys/kernel/randomize_va_space' before to start the build) but I do 
not use these builds in X,

$ /opt/emacs/bin/emacs

starts Emacs in the WSL terminal (aka DOS command prompt window in W10). 
It seems to work fine.. but have found an issue with the packages 
manager. See: 
http://lists.gnu.org/archive/html/bug-gnu-emacs/2016-12/msg00777.html.

Have you tried to use your builds in terminal mode (noX)?

Angelo



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 21:19     ` Angelo Graziosi
@ 2016-12-20 22:01       ` Fabrice Popineau
  0 siblings, 0 replies; 25+ messages in thread
From: Fabrice Popineau @ 2016-12-20 22:01 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1188 bytes --]

2016-12-20 22:19 GMT+01:00 Angelo Graziosi <angelo.graziosi@alice.it>:

> Il 20/12/2016 13:20, Fabrice Popineau ha scritto:
>
>> For the record,
>>
>> Emacs 25.1 builds fine and runs fine under WSL providing you install all
>> the required packages.
>> I used :
>>  ../emacs/configure --with-jpeg --with-xpm --with-tiff --with-rsvg
>> --with-xml2 --with-gnutls --with-imagemagick --with-png=yes
>> and mobaxterm as an X server. Everything is ok. I could even load
>> Spacemacs
>> with its about 100 packages.
>>
>>
> Yes, emacs-25 branch builds (adopting the work around 'echo 0 | sudo tee
> /proc/sys/kernel/randomize_va_space' before to start the build) but I do
> not use these builds in X,
>
> $ /opt/emacs/bin/emacs
>
> starts Emacs in the WSL terminal (aka DOS command prompt window in W10).
> It seems to work fine.. but have found an issue with the packages manager.
> See: http://lists.gnu.org/archive/html/bug-gnu-emacs/2016-12/msg00777.html
> .
>
> Have you tried to use your builds in terminal mode (noX)?
>
>
The problem seems to be with running emacs in the console.
It is working as expected in GUI mode, but in the the terminal, it is
suspended every key I type.

Fabrice

[-- Attachment #2: Type: text/html, Size: 1940 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 20:03         ` Fabrice Popineau
@ 2016-12-20 23:59           ` Angelo Graziosi
  2016-12-21  3:20           ` Paul Eggert
  1 sibling, 0 replies; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-20 23:59 UTC (permalink / raw)
  To: Fabrice Popineau, Paul Eggert; +Cc: Emacs developers

Il 20/12/2016 21:03, Fabrice Popineau ha scritto:
> I surely don't expect my "fix" to be included in master.
> It is only a quick way to make emacs master run under WSL for those who
> want to test it.
> WSL (IMHO) is still a work in progress.
> Once Ubuntu 16.04 will be available, maybe we should consider it more
> seriously.
> And even with 16.04, I wonder if it can compete with MSYS2/MinGW64.
> It needs to be rock solid for that.

In any case, this maybe interesting:

https://blogs.msdn.microsoft.com/wsl/2016/10/19/windows-and-ubuntu-interoperability/

Angelo



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 20:03         ` Fabrice Popineau
  2016-12-20 23:59           ` Angelo Graziosi
@ 2016-12-21  3:20           ` Paul Eggert
  2016-12-21  8:54             ` Angelo Graziosi
  1 sibling, 1 reply; 25+ messages in thread
From: Paul Eggert @ 2016-12-21  3:20 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: Angelo Graziosi, Emacs developers

[-- Attachment #1: Type: text/plain, Size: 882 bytes --]

Fabrice Popineau wrote:
> WSL (IMHO) is still a work in progress.
> Once Ubuntu 16.04 will be available, maybe we should consider it more
> seriously.

Is the goal for people to be able to build Emacs on Ubuntu 16.04, and run it 
under WSL? If so, that might be enough for now, and we wouldn't have to change 
Emacs.

I see my test program didn't output enough info, and had a typo. Could you 
please try the attached one instead? On Ubuntu 16.04.1 x86-64, this new program 
outputs:

personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers0 | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully
personality (0xffffffff) returns 0x40000, errno=0 (Success)

and when run under GDB, it outputs:

personality (0xffffffff) returns 0x40000, errno=0 (Success)
ADDR_NO_RANDOMIZE was set

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: personality.c --]
[-- Type: text/x-csrc; name="personality.c", Size: 1122 bytes --]

#include <sys/personality.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

static int
print_personality (unsigned long persona, char const *msg)
{
  int pers, err;
  errno = 0;
  pers = personality (persona);
  err = errno;
  printf ("personality (%s) returns 0x%x, errno=%d (%s)\n",
	  msg, pers, err, strerror (err));
  errno = err;
  return pers;
}

int
main (void)
{
  int pers0, pers1, pers2;
  pers0 = print_personality (0xffffffff, "0xffffffff");
  if (pers0 & ADDR_NO_RANDOMIZE)
    printf ("ADDR_NO_RANDOMIZE was set\n");
  else
    {
      printf ("ADDR_NO_RANDOMIZE was clear\n");
      pers1 = print_personality (pers0 | ADDR_NO_RANDOMIZE,
				"pers0 | ADDR_NO_RANDOMIZE");
      if (pers1 < 0)
	printf ("ADDR_NO_RANDOMIZE could not be set\n");
      else
	{
	  if (pers1 != pers0)
	    printf ("pers1 != pers0 ?\n");
	  printf ("ADDR_NO_RANDOMIZE set successfully\n");
	  pers2 = print_personality (0xffffffff, "0xffffffff");
	  if (pers2 != (pers0 | ADDR_NO_RANDOMIZE))
	    printf ("pers2 != (pers0 | ADDR_NO_RANDOMIZE) ?\n");
	}
    }
  return 0;
}

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-21  3:20           ` Paul Eggert
@ 2016-12-21  8:54             ` Angelo Graziosi
  2016-12-21 18:00               ` Paul Eggert
  0 siblings, 1 reply; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-21  8:54 UTC (permalink / raw)
  To: Paul Eggert, Fabrice Popineau; +Cc: Emacs developers

Hmmm...

Il 21/12/2016 04:20, Paul Eggert ha scritto:
>
> I see my test program didn't output enough info, and had a typo. Could
> you please try the attached one instead? On Ubuntu 16.04.1 x86-64, this
> new program outputs:
>
> personality (0xffffffff) returns 0x0, errno=0 (Success)
> ADDR_NO_RANDOMIZE was clear
> personality (pers0 | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
> ADDR_NO_RANDOMIZE set successfully
> personality (0xffffffff) returns 0x40000, errno=0 (Success)

$ gcc -std=gnu11 -g3 -O2 personality.c -o personality

$ ./personality
personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers0 | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully
personality (0xffffffff) returns 0x0, errno=0 (Success)
pers2 != (pers0 | ADDR_NO_RANDOMIZE) ?

>
> and when run under GDB, it outputs:
>
> personality (0xffffffff) returns 0x40000, errno=0 (Success)
> ADDR_NO_RANDOMIZE was set

$ gdb ./personality
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
[...]
(gdb) run
Starting program: /home/angelog/work/ports-packages/emacs/personality
warning: Error disabling address space randomization: Successo
warning: linux_ptrace_test_ret_to_nx: PTRACE_KILL waitpid returned -1: 
Chiamata di sistema interrotta
personality (0xffffffff) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE was clear
personality (pers0 | ADDR_NO_RANDOMIZE) returns 0x0, errno=0 (Success)
ADDR_NO_RANDOMIZE set successfully
personality (0xffffffff) returns 0x0, errno=0 (Success)
pers2 != (pers0 | ADDR_NO_RANDOMIZE) ?
[Inferior 1 (process 72) exited normally]
(gdb) q

which looks a bit different...

Ciao,
  Angelo.



^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-20 12:40     ` Fabrice Popineau
  2016-12-20 19:35       ` Paul Eggert
@ 2016-12-21  9:00       ` Angelo Graziosi
  2016-12-21 10:29         ` Fabrice Popineau
  1 sibling, 1 reply; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-21  9:00 UTC (permalink / raw)
  To: Fabrice Popineau; +Cc: Emacs developers



Il 20/12/2016 13:40, Fabrice Popineau ha scritto:
> However, there is a simple fix:
>
> diff --git a/src/emacs.c b/src/emacs.c
> index dc13b15..46a0593 100644
> --- a/src/emacs.c
> +++ b/src/emacs.c
> @@ -699,6 +699,7 @@ main (int argc, char **argv)
>    bool disable_aslr = dumping;
>  # endif
>
> +#if 0
>    if (disable_aslr && disable_address_randomization ())
>      {
>        /* Set this so the personality will be reverted before execs
> @@ -712,6 +713,7 @@ main (int argc, char **argv)
>        /* If the exec fails, warn and then try anyway.  */
>        perror (argv[0]);
>      }
> +#endif
>
>  #ifndef CANNOT_DUMP
>    might_dump = !initialized;
>
> Now, Spacemacs loads as well with master.

Yes, Emacs master builds and works in console (same issue for packages 
manager, bug #25221) but I have to

echo 0 | sudo tee /proc/sys/kernel/randomize_va_space

before the build starts otherwise it fails.

Angelo





^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-21  9:00       ` Angelo Graziosi
@ 2016-12-21 10:29         ` Fabrice Popineau
  0 siblings, 0 replies; 25+ messages in thread
From: Fabrice Popineau @ 2016-12-21 10:29 UTC (permalink / raw)
  To: Angelo Graziosi; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]

2016-12-21 10:00 GMT+01:00 Angelo Graziosi <angelo.graziosi@alice.it>:

> Il 20/12/2016 13:40, Fabrice Popineau ha scritto:
>
>> However, there is a simple fix:
>>
>> diff --git a/src/emacs.c b/src/emacs.c
>> index dc13b15..46a0593 100644
>> --- a/src/emacs.c
>> +++ b/src/emacs.c
>> @@ -699,6 +699,7 @@ main (int argc, char **argv)
>>    bool disable_aslr = dumping;
>>  # endif
>>
>> +#if 0
>>    if (disable_aslr && disable_address_randomization ())
>>      {
>>        /* Set this so the personality will be reverted before execs
>> @@ -712,6 +713,7 @@ main (int argc, char **argv)
>>        /* If the exec fails, warn and then try anyway.  */
>>        perror (argv[0]);
>>      }
>> +#endif
>>
>>  #ifndef CANNOT_DUMP
>>    might_dump = !initialized;
>>
>> Now, Spacemacs loads as well with master.
>>
>
> Yes, Emacs master builds and works in console (same issue for packages
> manager, bug #25221) but I have to
>
> echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
>
> before the build starts otherwise it fails.
>
>
Yes, this is needed and that won't change until unexec is removed from
emacs (either replace by portable dumper or loading everything at runtime).

-- 
Fabrice

[-- Attachment #2: Type: text/html, Size: 2018 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-21  8:54             ` Angelo Graziosi
@ 2016-12-21 18:00               ` Paul Eggert
  2016-12-21 20:50                 ` Angelo Graziosi
  0 siblings, 1 reply; 25+ messages in thread
From: Paul Eggert @ 2016-12-21 18:00 UTC (permalink / raw)
  To: Angelo Graziosi, Fabrice Popineau; +Cc: Emacs developers

[-- Attachment #1: Type: text/plain, Size: 241 bytes --]

Thanks. I think I see the problem now. I installed the attached patch 
into master. Although a similar patch presumably would be useful in 
emacs-25, it's a bit late in the day to be fiddling with emacs-25 merely 
to port to a new platform.

[-- Attachment #2: 0001-Port-dumping-better-to-WSL.patch --]
[-- Type: application/x-patch, Size: 1245 bytes --]

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: Building Emacs on WSL
  2016-12-21 18:00               ` Paul Eggert
@ 2016-12-21 20:50                 ` Angelo Graziosi
  0 siblings, 0 replies; 25+ messages in thread
From: Angelo Graziosi @ 2016-12-21 20:50 UTC (permalink / raw)
  To: Paul Eggert, Fabrice Popineau; +Cc: Emacs developers

Il 21/12/2016 19:00, Paul Eggert ha scritto:
> Thanks. I think I see the problem now. I installed the attached patch
> into master. Although a similar patch presumably would be useful in
> emacs-25, it's a bit late in the day to be fiddling with emacs-25 merely
> to port to a new platform.

Indeed. Thanks for the patch.

Angelo



^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2016-12-21 20:50 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-11 17:42 Building Emacs on WSL Angelo Graziosi
2016-12-16 15:05 ` Angelo Graziosi
2016-12-16 15:30   ` Eli Zaretskii
2016-12-16 17:48     ` Paul Eggert
2016-12-16 21:05       ` Eli Zaretskii
2016-12-17  1:00         ` Angelo Graziosi
2016-12-17  8:02           ` Eli Zaretskii
2016-12-17  8:33             ` Angelo Graziosi
2016-12-17 10:55               ` Eli Zaretskii
2016-12-17 14:25           ` Eli Zaretskii
2016-12-17 15:46             ` Angelo Graziosi
2016-12-20 12:20   ` Fabrice Popineau
2016-12-20 12:40     ` Fabrice Popineau
2016-12-20 19:35       ` Paul Eggert
2016-12-20 20:03         ` Fabrice Popineau
2016-12-20 23:59           ` Angelo Graziosi
2016-12-21  3:20           ` Paul Eggert
2016-12-21  8:54             ` Angelo Graziosi
2016-12-21 18:00               ` Paul Eggert
2016-12-21 20:50                 ` Angelo Graziosi
2016-12-20 20:57         ` Angelo Graziosi
2016-12-21  9:00       ` Angelo Graziosi
2016-12-21 10:29         ` Fabrice Popineau
2016-12-20 21:19     ` Angelo Graziosi
2016-12-20 22:01       ` Fabrice Popineau

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).