Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Generated executables have missing execute bit #555

Closed
0xmohit opened this issue Mar 25, 2016 · 7 comments · Fixed by dotnet/fsharp#2950
Closed

Generated executables have missing execute bit #555

0xmohit opened this issue Mar 25, 2016 · 7 comments · Fixed by dotnet/fsharp#2950

Comments

@0xmohit
Copy link

0xmohit commented Mar 25, 2016

$  uname -a
Linux earth 4.2.0-34-generic #39-Ubuntu SMP Thu Mar 10 22:13:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

F# obtained as per instructions on http://fsharp.org/use/linux/.

Test file:

$  cat a.fs 
printfn "Hey"

Now compile:

$  fsharpc --nologo a.fs 

Check the result:

$  ls -l
total 8
-rw-rw-r-- 1 mohit mohit 3584 Mar 25 20:27 a.exe
-rw-rw-r-- 1 mohit mohit   14 Mar 25 20:07 a.fs

The executable a.exe doesn't have the execute bit set.

In case it matters, here's the umask:

$  umask 
0002

The compiler version from fsharpc --help reads F# Compiler for F# 4.0 (Open Source Edition)

@smoothdeveloper
Copy link
Contributor

@0xmohit I think you anyways need to execute the program like this:

mono a.exe so I don't think it really matters.

What is the behaviour of C# compiler?

@0xmohit
Copy link
Author

0xmohit commented Mar 25, 2016

Executables generated by mcs don't exhibit this behavior, i.e. mcs foo.cs generates foo.exe which has the execute bit(s) set.

@0xmohit
Copy link
Author

0xmohit commented Mar 25, 2016

It is worthwhile adding that this issue (with fsharpc) wasn't observed earlier -- seems that the change is due to a recent package update.

@dsyme
Copy link
Contributor

dsyme commented Mar 30, 2016

The code to set the executable permissions is here: https://github.com/fsharp/fsharp/blob/master/src/absil/ilwrite.fs#L3414

It might be that this code is now failing for some reason on recent Mono configurations, e.g. due to assembly number version changes or the like.

If someone could check (e.g. by putting the relevant subset of the code through F# Interactive) that would be great.

@0xmohit
Copy link
Author

0xmohit commented Apr 2, 2016

It might be that this code is now failing for some reason on recent Mono configurations, e.g. due to assembly number version changes or the like.

Compiling with FSharp_DebugSetFilePermissions set, i.e. by saying

    FSharp_DebugSetFilePermissions=1 fsharpc a.fs

yields:

F# Compiler for F# 4.0 (Open Source Edition)
Freely distributed under the Apache 2.0 Open Source License
loading type Mono.Unix.UnixFileInfo...
failure: System.MissingMethodException: Method 'Mono.Unix.UnixFileSystemInfo.set_FileAccessPermissions' not found.
  at System.RuntimeType.InvokeMember (System.String name, BindingFlags bindingFlags, System.Reflection.Binder binder, System.Object target, System.Object[] providedArgs, System.Reflection.ParameterModifier[] modifiers, System.Globalization.CultureInfo culture, System.String[] namedParams) <0x7f7f247f8190 + 0x015d6> in <filename unknown>:0 
  at System.Type.InvokeMember (System.String name, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object target, System.Object[] args, System.Globalization.CultureInfo culture) <0x7f7f248c8810 + 0x0005e> in <filename unknown>:0 
  at Microsoft.FSharp.Compiler.AbstractIL.ILBinaryWriter+FileSystemUtilites.setExecutablePermission[a] (a filename) <0x403fb700 + 0x002a8> in <filename unknown>:0 ...

@dsyme
Copy link
Contributor

dsyme commented Apr 3, 2016

Ok, well, that's the problem certainly. But I don't understand why that reflection call is now failing. Calling the getter property succeeds, and the setter is public https://github.com/mono/mono/blob/master/mcs/class/Mono.Posix/Mono.Unix/UnixFileSystemInfo.cs#L134

It could be that the argument to the setter method is considered a boxed Int32 instead of a boxed FileAccessPermissions enumeration, and the reflection machinery is no longer applying an auto-conversion. But that would be a strange breaking change in reflection. Still, it's the only explanation I can think of.

If someone would like to trial a fix that would be great.

@dsyme
Copy link
Contributor

dsyme commented Apr 29, 2017

Fixed by dotnet/fsharp#2950

@dsyme dsyme closed this as completed Apr 29, 2017
dsyme added a commit to dotnet/fsharp that referenced this issue Apr 29, 2017
realvictorprm pushed a commit to realvictorprm/visualfsharp that referenced this issue Apr 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants