unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] src/makefile.w32-in
@ 2008-01-16 20:26 Bill Meier
  2008-01-17  9:40 ` Jason Rumney
  0 siblings, 1 reply; 7+ messages in thread
From: Bill Meier @ 2008-01-16 20:26 UTC (permalink / raw)
  To: bug-gnu-emacs

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

After doing a build of emacs on Windows with MinGW (configure, make bootstrap,
.., make install) I found that then doing a make clean, make failed.

Specifically: there was an "access denied" message for temacs.exe during the
make step. (I'm new to building emacs on Windows but presumably a make clean,
make after the original build should work).

After a little poking around I discovered that the problem is that during the
build a dummy temacs.exe file is being created with only rw permissions (see
lib-src/makefile).

Later in the build, when temacs.exe is created from temacs.bin by using
addsection, apparently the permissions (rw) from the existing temacs.exe file
are kept thus resulting in a temacs.exe file without executable permission.

So: the simple fix I've done is to delete any existing temacs.exe file just
before using addsection to create the file.

The attachment with a fix is a diff -u against the current HEAD
src/makefile.w32-in (revision 1.56).

Bill Meier

[-- Attachment #2: src-makefile-w32-in-patch.diff --]
[-- Type: application/octet-stream, Size: 996 bytes --]

--- src/makefile.w32-in-orig	2008-01-16 14:38:56.575606400 -0500
+++ src/makefile.w32-in	2008-01-16 14:44:56.763531200 -0500
@@ -168,11 +168,16 @@
 # Note the extra post-link step to insert a static preload heap section.
 # If preload runs out of memory, increase the last argument to addsection
 # (it is the preload heap size in MB).
+# Note that a (possibly dummy) temacs.exe is deleted before the post-link step.
+#  This is required so that the permissions for the new temacs.exe are not inherited
+#  from an existing one (which might not have 'executable' permission). 
+#  (See lib-src makefile).
 #
 temacs:         stamp_BLD $(TEMACS)
 $(TEMACS):      $(TLIB0) $(TLIB1) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES) \
 		  ../nt/$(BLD)/addsection.exe
 	$(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
+	- $(DEL) "$(TEMACS)"
 	"../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 16
 	echo $(OBJ0) > $(BLD)/buildobj.lst
 	echo $(OBJ1) >> $(BLD)/buildobj.lst

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

* Re: [PATCH] src/makefile.w32-in
  2008-01-16 20:26 [PATCH] src/makefile.w32-in Bill Meier
@ 2008-01-17  9:40 ` Jason Rumney
  2008-01-20 16:30   ` Bill Meier
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Rumney @ 2008-01-17  9:40 UTC (permalink / raw)
  To: Bill Meier; +Cc: bug-gnu-emacs

Bill Meier wrote:
> After a little poking around I discovered that the problem is that during the
> build a dummy temacs.exe file is being created with only rw permissions (see
> lib-src/makefile).
>
> Later in the build, when temacs.exe is created from temacs.bin by using
> addsection, apparently the permissions (rw) from the existing temacs.exe file
> are kept thus resulting in a temacs.exe file without executable permission.
>   

I'm confused, what permissions are you talking about? Windows does not 
use POSIX permissions, all readable .exe files are considered executable.





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

* Re: [PATCH] src/makefile.w32-in
  2008-01-17  9:40 ` Jason Rumney
@ 2008-01-20 16:30   ` Bill Meier
  2008-01-20 21:50     ` Jason Rumney
  0 siblings, 1 reply; 7+ messages in thread
From: Bill Meier @ 2008-01-20 16:30 UTC (permalink / raw)
  To: bug-gnu-emacs

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

Jason Rumney wrote:
> I'm confused, what permissions are you talking about? Windows does not 
> use POSIX permissions, all readable .exe files are considered executable.

I'm not really familiar with the details of Windows file permissions
so the easiest way for me to respond is to say that in
my Windows environment (see below) a 'mingw32-make clean'
followed by a 'mingw32-make' fails with a
'permission denied' for temacs.exe.

###Annotated)
   $mingw32-make clean
   <snip>
   $mingw32-make
   <snip>
   "../nt/oo-spd/i386/addsection" "oo-spd/i386/temacs.bin" 
"oo-spd/i386/temacs.exe" EMHEAP 16
   Dumping from oo-spd/i386/temacs.bin
             to oo-spd/i386/temacs.exe
   echo oo-spd/i386/emacs.o > oo-spd/i386/buildobj.lst
   <snip>
   "./oo-spd/i386/temacs.exe" -batch -l loadup dump
   /usr/bin/sh: ./oo-spd/i386/temacs.exe: Permission denied
   mingw32-make[1]: *** [oo-spd/i386/emacs.exe] Error 126
   mingw32-make[1]: Leaving directory `C:/emacs-22.1.1/src'
   mingw32-make: *** [all-other-dirs-gmake] Error 2

   ### The following shows the 'permissions' of temacs.exe at
   ### this point
   $cacls c:\emacs-22.1.1\src\oo-spd\i386\temacs.exe
   c:\emacs-22.1.1\src\oo-spd\i386\temacs.exe xxx\wmeier:(special access:)
                           STANDARD_RIGHTS_ALL
                           DELETE
                           READ_CONTROL
                           WRITE_DAC
                           WRITE_OWNER
                           SYNCHRONIZE
                           STANDARD_RIGHTS_REQUIRED
                           FILE_GENERIC_READ
                           FILE_GENERIC_WRITE
                           FILE_READ_DATA
                           FILE_WRITE_DATA
                           FILE_APPEND_DATA
                           FILE_READ_EA
                           FILE_WRITE_EA
                           FILE_READ_ATTRIBUTES
                           FILE_WRITE_ATTRIBUTES

             BUILTIN\Users:(special access:)
                           READ_CONTROL
                           SYNCHRONIZE
                           FILE_GENERIC_READ
                           FILE_GENERIC_WRITE
                           FILE_READ_DATA
                           FILE_WRITE_DATA
                           FILE_APPEND_DATA
                           FILE_READ_EA
                           FILE_WRITE_EA
                           FILE_READ_ATTRIBUTES
                           FILE_WRITE_ATTRIBUTES

             Everyone:(special access:)
                      READ_CONTROL
                      SYNCHRONIZE
                      FILE_GENERIC_READ
                      FILE_GENERIC_WRITE
                      FILE_READ_DATA
                      FILE_WRITE_DATA
                      FILE_APPEND_DATA
                      FILE_READ_EA
                      FILE_WRITE_EA
                      FILE_READ_ATTRIBUTES
                      FILE_WRITE_ATTRIBUTES

-------------------------------------------------------------
My environment (which I think is nothing out of the ordinary)
    Windows XP (patched) using NTFS file structure
    MinGW (for gcc, mingw32-make & etc)
    Cygwin (for bash & etc)

-------------------------------------------------------------
As described previously, some poking around shows that the
problem is due to the fact that a dummy temacs.exe file
without 'execute' permission exists
when addsection is run in src/makefile.
The dummy file is created in lib-src/makefile.
The simple solution to the problem is to delete the dummy file
just before runing addsection to create the real
temacs.exe.

I've attached a patch to do this against the EMACS_22_BASE 
src/makefile.w32-in

=============================================================

### Some gory details
### Demonstration of the problem
###

### Create dummy temacs.exe and then run addsection;
###  Then: Cannot execute temacs.exe

$ cd c:\emacs-22.1\src
$bash
bash-3.2$ echo temacs > oo-spd/i386/temacs.exe
bash-3.2$ cacls oo-spd/i386/temacs.exe
C:\emacs-22.1.1\src\oo-spd\i386\temacs.exe xxx\wmeier:(special access:)
                            STANDARD_RIGHTS_ALL
                            DELETE
                            READ_CONTROL
                            WRITE_DAC
                            WRITE_OWNER
                            SYNCHRONIZE
                            STANDARD_RIGHTS_REQUIRED
                            FILE_GENERIC_READ
                            FILE_GENERIC_WRITE
                            FILE_READ_DATA
                            FILE_WRITE_DATA
                            FILE_APPEND_DATA
                            FILE_READ_EA
                            FILE_WRITE_EA
                            FILE_READ_ATTRIBUTES
                            FILE_WRITE_ATTRIBUTES

              BUILTIN\Users:(special access:)
                            READ_CONTROL
                            SYNCHRONIZE
                            FILE_GENERIC_READ
                            FILE_GENERIC_WRITE
                            FILE_READ_DATA
                            FILE_WRITE_DATA
                            FILE_APPEND_DATA
                            FILE_READ_EA
                            FILE_WRITE_EA
                            FILE_READ_ATTRIBUTES
                            FILE_WRITE_ATTRIBUTES

              Everyone:(special access:)
                       READ_CONTROL
                       SYNCHRONIZE
                       FILE_GENERIC_READ
                       FILE_GENERIC_WRITE
                       FILE_READ_DATA
                       FILE_WRITE_DATA
                       FILE_APPEND_DATA
                       FILE_READ_EA
                       FILE_WRITE_EA
                       FILE_READ_ATTRIBUTES
                       FILE_WRITE_ATTRIBUTES


bash-3.2$ "../nt/oo-spd/i386/addsection" "oo-spd/i386/temacs.bin" 
"oo-spd/i386/temacs.exe" EMHEAP 16
Dumping from oo-spd/i386/temacs.bin
           to oo-spd/i386/temacs.exe

bash-3.2$ ./oo-spd/i386/temacs.exe -l -batch loadup dump
bash: ./oo-spd/i386/temacs.exe: Permission denied

bash-3.2$ cacls oo-spd/i386/temacs.exe
C:\emacs-22.1.1\src\oo-spd\i386\temacs.exe xxx\wmeier:(special access:)
                            STANDARD_RIGHTS_ALL
                            DELETE
                            READ_CONTROL
                            WRITE_DAC
                            WRITE_OWNER
                            SYNCHRONIZE
                            STANDARD_RIGHTS_REQUIRED
                            FILE_GENERIC_READ
                            FILE_GENERIC_WRITE
                            FILE_READ_DATA
                            FILE_WRITE_DATA
                            FILE_APPEND_DATA
                            FILE_READ_EA
                            FILE_WRITE_EA
                            FILE_READ_ATTRIBUTES
                            FILE_WRITE_ATTRIBUTES

              BUILTIN\Users:(special access:)
                            READ_CONTROL
                            SYNCHRONIZE
                            FILE_GENERIC_READ
                            FILE_GENERIC_WRITE
                            FILE_READ_DATA
                            FILE_WRITE_DATA
                            FILE_APPEND_DATA
                            FILE_READ_EA
                            FILE_WRITE_EA
                            FILE_READ_ATTRIBUTES
                            FILE_WRITE_ATTRIBUTES

              Everyone:(special access:)
                       READ_CONTROL
                       SYNCHRONIZE
                       FILE_GENERIC_READ
                       FILE_GENERIC_WRITE
                       FILE_READ_DATA
                       FILE_WRITE_DATA
                       FILE_APPEND_DATA
                       FILE_READ_EA
                       FILE_WRITE_EA
                       FILE_READ_ATTRIBUTES
                       FILE_WRITE_ATTRIBUTES

### Creating temacs.exe in the absence of the dummy file
###  works AOK

bash-3.2$ rm oo-spd/i386/temacs.exe
bash-3.2$ "../nt/oo-spd/i386/addsection" "oo-spd/i386/temacs.bin" 
"oo-spd/i386/temacs.exe" EMHEAP 16
Dumping from oo-spd/i386/temacs.bin
           to oo-spd/i386/temacs.exe
bash-3.2$ ./oo-spd/i386/temacs.exe -l -batch loadup dump
bash-3.2$ cacls oo-spd/i386/temacs.exe

C:\emacs-22.1.1\src\oo-spd\i386\temacs.exe xxx\wmeier:F
              BUILTIN\Users:(special access:)
                            READ_CONTROL
                            SYNCHRONIZE
                            FILE_GENERIC_READ
                            FILE_GENERIC_WRITE
                            FILE_GENERIC_EXECUTE
                            FILE_READ_DATA
                            FILE_WRITE_DATA
                            FILE_APPEND_DATA
                            FILE_READ_EA
                            FILE_WRITE_EA
                            FILE_EXECUTE
                            FILE_DELETE_CHILD
                            FILE_READ_ATTRIBUTES
                            FILE_WRITE_ATTRIBUTES

              Everyone:(special access:)
                       READ_CONTROL
                       SYNCHRONIZE
                       FILE_GENERIC_READ
                       FILE_GENERIC_WRITE
                       FILE_GENERIC_EXECUTE
                       FILE_READ_DATA
                       FILE_WRITE_DATA
                       FILE_APPEND_DATA
                       FILE_READ_EA
                       FILE_WRITE_EA
                       FILE_EXECUTE
                       FILE_DELETE_CHILD
                       FILE_READ_ATTRIBUTES
                       FILE_WRITE_ATTRIBUTES



[-- Attachment #2: patch-src-makefile-w32-in.txt --]
[-- Type: text/plain, Size: 996 bytes --]

--- src\makefile.w32-in-orig	2008-01-20 10:24:26.150886400 -0500
+++ src\makefile.w32-in	2008-01-20 10:29:14.345289600 -0500
@@ -168,11 +168,16 @@
 # Note the extra post-link step to insert a static preload heap section.
 # If preload runs out of memory, increase the last argument to addsection
 # (it is the preload heap size in MB).
+# Note that a (possibly dummy) temacs.exe is deleted before the post-link step.
+#  This is required so that the permissions for the new temacs.exe are not inherited
+#  from an existing one (which might not have 'executable' permission). 
+#  (See lib-src makefile).
 #
 temacs:         stamp_BLD $(TEMACS)
 $(TEMACS):      $(TLIB0) $(TLIB1) $(TLIBW32) $(TLASTLIB) $(TOBJ) $(TRES) \
 		  ../nt/$(BLD)/addsection.exe
 	$(LINK) $(LINK_OUT)$(TEMACS_TMP) $(FULL_LINK_FLAGS) $(TOBJ) $(TRES) $(LIBS)
+	- $(DEL) "$(TEMACS)"
 	"../nt/$(BLD)/addsection" "$(TEMACS_TMP)" "$(TEMACS)" EMHEAP 16
 	echo $(OBJ0) > $(BLD)/buildobj.lst
 	echo $(OBJ1) >> $(BLD)/buildobj.lst

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

* Re: [PATCH] src/makefile.w32-in
  2008-01-20 16:30   ` Bill Meier
@ 2008-01-20 21:50     ` Jason Rumney
  2008-01-20 22:46       ` Bill Meier
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Rumney @ 2008-01-20 21:50 UTC (permalink / raw)
  To: Bill Meier; +Cc: bug-gnu-emacs

Bill Meier wrote:
> Jason Rumney wrote:
>> I'm confused, what permissions are you talking about? Windows does 
>> not use POSIX permissions, all readable .exe files are considered 
>> executable.
>
> I'm not really familiar with the details of Windows file permissions
> so the easiest way for me to respond is to say that in
> my Windows environment (see below) a 'mingw32-make clean'
> followed by a 'mingw32-make' fails with a
> 'permission denied' for temacs.exe.

Since the offending command is an echo, which is a shell built-in, which 
shell are you using to build Emacs? It seems to be one that we haven't 
encountered before, so there may be other problems.




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

* Re: [PATCH] src/makefile.w32-in
  2008-01-20 21:50     ` Jason Rumney
@ 2008-01-20 22:46       ` Bill Meier
  2008-01-20 23:20         ` Jason Rumney
  0 siblings, 1 reply; 7+ messages in thread
From: Bill Meier @ 2008-01-20 22:46 UTC (permalink / raw)
  To: bug-gnu-emacs

Jason Rumney wrote:

> Since the offending command is an echo, which is a shell built-in, which 
> shell are you using to build Emacs? It seems to be one that we haven't 
> encountered before, so there may be other problems.

Nothing special: A current cygwin bash (invoked as 'sh') ....

   $mingw32-make which-sh
   [Please ignore a syntax error on the next line - it is intentional]
   /usr/bin/sh: -c: line 0: unexpected EOF while looking for matching `"'
   /usr/bin/sh: -c: line 1: syntax error: unexpected end of file
   Using c:/cygwin/bin/sh.exe as shell.
   c:/cygwin/bin/sh.exe --version
   GNU bash, version 3.2.33(18)-release (i686-pc-cygwin)
   Copyright (C) 2007 Free Software Foundation, Inc.

[For the above: '$(SHELL) --version' added to the cmds for
the which-sh target ....]

Please note that once I apply the patch to delete the dummy temacs.exe 
file, 'mingw32-make clean' / 'mingw32-make'  works just fine and gives 
me a working Windows emacs.

Bill Meier





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

* Re: [PATCH] src/makefile.w32-in
  2008-01-20 22:46       ` Bill Meier
@ 2008-01-20 23:20         ` Jason Rumney
  2008-01-20 23:39           ` Bill Meier
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Rumney @ 2008-01-20 23:20 UTC (permalink / raw)
  To: Bill Meier; +Cc: bug-gnu-emacs

Bill Meier wrote:
> Please note that once I apply the patch to delete the dummy temacs.exe 
> file, 'mingw32-make clean' / 'mingw32-make'  works just fine and gives 
> me a working Windows emacs.

I've just checked in a different patch, to disable the Cygwin misfeature 
of trying to map unix file permissions onto NTFS ACLs. This should avoid 
any other such problems that might be lurking, now and in the future.





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

* Re: [PATCH] src/makefile.w32-in
  2008-01-20 23:20         ` Jason Rumney
@ 2008-01-20 23:39           ` Bill Meier
  0 siblings, 0 replies; 7+ messages in thread
From: Bill Meier @ 2008-01-20 23:39 UTC (permalink / raw)
  To: bug-gnu-emacs

Jason Rumney wrote:
> I've just checked in a different patch, to disable the Cygwin misfeature 
> of trying to map unix file permissions onto NTFS ACLs. This should avoid 
> any other such problems that might be lurking, now and in the future.

Thanks

Bill Meier








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

end of thread, other threads:[~2008-01-20 23:39 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-16 20:26 [PATCH] src/makefile.w32-in Bill Meier
2008-01-17  9:40 ` Jason Rumney
2008-01-20 16:30   ` Bill Meier
2008-01-20 21:50     ` Jason Rumney
2008-01-20 22:46       ` Bill Meier
2008-01-20 23:20         ` Jason Rumney
2008-01-20 23:39           ` Bill Meier

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).