Giter Club home page Giter Club logo

bflat's People

Contributors

lucabol avatar michalstrehovsky avatar theonly112 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bflat's Issues

Any plans to support 32bit ARM targets

Hey. Awesome project. Quick question: Do you have any plans to support 32bit targets? Would be awesome to use bflat with low-cost MCUs. Thanks. Peter

Windows driver

Hello!

Since this can even run in EFI, I wonder if it's possible to write a windows kernel-mode driver in C# with the help of zerolib? I think that'll be pretty cool.

Ability to process folder recursively for build

gcc++, for example, has the ability to build all files in specified folder: "${fileDirname}/*.cpp

The reason I ask the same for bflat is because right now, just making basic task for VSCode turns into miserable experience:

  1. I either have to accept limitations and remember never use spaces in file/folder names and dont use very long pathnames (which may become problem if few dozen files present for the arg length limit)
  2. Write my own wrapper that will provide ready to use args for bflat but this kills portability (you cant just sync tasks.json you now have to have the tool as well)

etc, etc

Something like:
bflat build -o D:\artifacts\whatever.exe --batch D:\project\mybflatthing
where file path now treated as folder path and will search all *.cs recursively.

Building on Linux

When attempting to build BFlat (the compiler itself) on Linux, at the project build step (not targets), I get

Failed to download file "https://github.com/bflattened/runtime/releases/download/v7.0.2-rtm.22631.1/bflat-compiler-native-.zip".  Response status code does not indicate success: 404 (Not Found).

Same nuget config successfully builds on Windows, so guessing it's something with my Linux setup. Running on x64 Manjaro Arch, same issue when running dotnet build on cli, or using Rider.

How does this interface with the actual hardware?

How does this interface with the actual hardware?
it looks like your screen buffer doesn't point to a memory address at all, it's just a fixed buffer.

I am looking into this for OS development as in building a micro kernel, drivers, and a desktop.
So far from the looks of the source code it's not really meant to be taken seriously.

Support for modules

bflat build (without arguments) currently builds all *.cs files in the current directory. Would be nice to be able to add source files from different directories. A directory corresponds to a module.

We can use an INI file format that looks like Rust's TOML but has less useless ceremony.

How to use --no-reflection flag but omit --no-stacktrace-data flag to see stack trace line numbers

When I compile my c# app using these flags:

bflat.exe build --os:windows --no-reflection --no-stacktrace-data --no-globalization --no-exception-messages --Os

then my app gives following exception:

[Exception!] -> EETypeRva:0x00057E60: Reflection_Disabled
   at App!<BaseAddress>+0x16278d
   at App!<BaseAddress>+0xeea6b
   at App!<BaseAddress>+0x16e0ec
   at App!<BaseAddress>+0xedf69
   at App!<BaseAddress>+0xede6c

If I omit "--no-stacktrace-data" aiming to see exact stack trace line numbers and use:

bflat.exe build --os:windows --no-reflection --no-globalization --no-exception-messages --Os

then the compiler gives following warning message:

ILC: AOT analysis warning IL1005:
Internal.StackTraceMetadata.StackTraceMetadata.GetMethodNameFromStartAddressIfAvailable(IntPtr): 
Method will always throw because: Failed to load assembly 'System.Private.Reflection.Core'

And if I execute my app .exe ignoring this ILC analysis warning, it fails without giving any stack trace info at all.

The only way for me seems to be working is to omit "--no-reflection" flag, but this leads to significantly larger file size sadly.

Windows 10 amd64, dotnet --version: 6.0.100-preview.5.21302.13.

I wonder if this is expected behavior or not?

HTTP Api, Lambda etc

Hi,
Can we use this to build any HTTP Api kinda thing or use in Lambda?

Thanks

sample for fast execution ?

Like you made sample to output minimalist executable with respect to file size,
are there any settings which focuses on speed and how further assembly can be made fast ?

Between I did small test.
C# executable was doing an work for 370ms.
And same code in bflat took 290ms.

Impressive !

Support taking Visual Studio .sln and .csproj as input

Most of the time, projects depending on each other. Processing each of them manually is very difficult because of circular dependency. It's better if we could process projects (.csproj) or a solution (.sln) directly as input.

Shared runtime

Suppose I'm shipping a product that includes several executables. Each of them will bundle the complete runtime, increasing the size of the application.

Would it be possible to (optionally) separate the runtime into a shared library for these cases?

we need some sort of project and solution structure

We need some sort of project and solution structure whether that be csproj files and sln files or just json or toml.
Part of what makes C# so great is it's build system, it's easy.
Calling bflat compiler or making sh/bat script really isn't going to do it.

Auto adding references/dependencies?

I'm trying to build a winforms code using .NET 7 shared DLLs.

using System;
using System.Windows.Forms;

Application.Run(new Form());

Build command:

$ cd dotnet-sdk-7.0.101-win-x64\shared\Microsoft.WindowsDesktop.App\7.0.1
$ bflat build main.cs -r System.Windows.Forms.dll --ldflags "/subsystem:windows"

Output:

...Failed to load assembly 'System.Windows.Forms.Primitives'

# added -r System.Windows.Forms.Primitives.dll
...Failed to load assembly 'System.Drawing.Common'

# added -r System.Drawing.Common.dll
...Failed to load assembly 'Accessibility'
...Failed to load assembly 'Microsoft.Win32.SystemEvents'

Finally, it's done after I added all missing dependencies by hand 😪

-r System.Windows.Forms.dll
-r System.Windows.Forms.Primitives.dll
-r System.Drawing.Common.dll
-r Accessibility.dll
-r Microsoft.Win32.SystemEvents.dll

I hope it should support as the title says,

or at least the -r option allows *.dll 😀


Licensing clarification

bflat is GPL-licensed.

  • The Zero runtime is under the same GPL license -> anything you link with this runtime also must be under GPL
  • I can not find license for the bflat customizations of the dotnet runtime so i suppose it is also GPL as the main project -> again anything you produce with the DotNet runtime must be under GPL

Does this means bflat is unsuitable for developing non-GPL software?

Add ability to embed files

Something like //go:embed, except not done as a tasteless comment.

Sounds like a task for a source generator. Maybe there's something that can be used for this available already.

Support of rd.xml (dynamic)

Program.cs referencing Brotli.Net.dll which uses Marshal/dynamic feature
the exe is generated but when run, it throw exception Type not found

I read online it says need to create rd.xml and set Dynamic="Require All". How to make bflat to use rd.xml?

Linux build of bflat

Linux build of the compiler can be produced, but currently fails at runtime due to #3. Apparently the C# compiler needs to compute the SHA hashes of source files it's compiling and the .NET libraries delegate SHA computations to libssl that we try to load with dlopen).

HttpClient does not seem to work

A sample application:

using System;
using System.Net.Http;

var http = new HttpClient();
var url = "https://google.com";
var resp = await http.GetAsync(url);
var contents = await resp.Content.ReadAsStringAsync();

Console.WriteLine($"Result is {contents.Length} bytes.");
Console.ReadLine();

Compiling it under Windows 10 produces an executable and a load of warning messages:

D:\work\bflat>bflat build test.cs
ILC: AOT analysis warning IL3055: System.Net.Quic.Implementations.MsQuic.Internal.MsQuicNativeMethods.SetCallbackHandlerDelegate.Invoke(SafeHandle,Delegate,IntPtr): P/invoke method 'Internal.CompilerGenerated.PInvokeDelegateWrapper__SetCallbackHandlerDelegate.ForwardNativeFunctionWrapper__SetCallbackHandlerDelegate(SafeHandle,Delegate,IntPtr)' declares a parameter with an abstract delegate. Correctness of interop for abstract delegates cannot be guaranteed after native compilation: the marshalling code for the delegate might not be available. Use a non-abstract delegate type or ensure any delegate instance passed as parameter is marked with `UnmanagedFunctionPointerAttribute`.
D:\a\runtime\runtime\src\libraries\System.Net.Quic\src\System\Net\Quic\Implementations\MsQuic\Interop\MsQuicNativeMethods.cs(154): AOT analysis warning IL3050: System.Net.Quic.Implementations.MsQuic.Internal.MsQuicNativeMethods.AnyDelegateMarshaller.AnyDelegateMarshaller(Delegate): Using member 'System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate(Delegate)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. Marshalling code for the delegate might not be available. Use the GetFunctionPointerForDelegate<TDelegate> overload instead.
D:\a\runtime\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshal.cs(177): AOT analysis warning IL3050: System.Runtime.InteropServices.Marshal.OffsetOf<T>(String): Using member 'System.Runtime.InteropServices.Marshal.OffsetOf(Type,String)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling.
D:\a\runtime\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\RuntimeHelpers.cs(52): AOT analysis warning IL3050: System.Runtime.CompilerServices.RuntimeHelpers.GetSubArray<T>(!!0[],Range): Using member 'System.Array.CreateInstance(Type,Int32)' which has 'RequiresDynamicCodeAttribute' can break functionality when AOT compiling. The native code for the array might not be available at runtime.
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<ReadAsyncInternal>d__179`1<System.Net.Security.AsyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<ReadAsyncInternal>d__179`1<System.Net.Security.SyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<<WriteSingleChunk>g__WaitAndWriteAsync|173_0>d`1<System.Net.Security.SyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<EnsureFullTlsFrameAsync>d__177`1<System.Net.Security.SyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<EnsureFullTlsFrameAsync>d__177`1<System.Net.Security.AsyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<ForceAuthenticationAsync>d__166`1<System.Net.Security.SyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<ForceAuthenticationAsync>d__166`1<System.Net.Security.AsyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream+<<WriteSingleChunk>g__WaitAndWriteAsync|173_0>d`1<System.Net.Security.AsyncReadWriteAdapter>.MoveNext()' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream.WriteSingleChunk<SyncReadWriteAdapter>(ReadOnlyMemory`1<uint8>,CancellationToken)' will always throw because: The format of a DLL or executable being loaded is invalid
ILC: Method '[System.Net.Security]System.Net.Security.SslStream.WriteSingleChunk<AsyncReadWriteAdapter>(ReadOnlyMemory`1<uint8>,CancellationToken)' will always throw because: The format of a DLL or executable being loaded is invalid

Running the executable produces an exception:

D:\work\bflat>test
Unhandled Exception: System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception.
 ---> System.BadImageFormatException: Format of the executable (.exe) or library (.dll) is invalid.
   at Internal.Runtime.CompilerHelpers.ThrowHelpers.ThrowBadImageFormatException(ExceptionStringID) + 0x31
   at System.Net.Security.SslStream.WriteSingleChunk[TIOAdapter](ReadOnlyMemory`1, CancellationToken) + 0xe
   at System.Runtime.CompilerServices.AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine&) + 0x40
   at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean, Byte[], CancellationToken) + 0x70
   at System.Net.Security.SslStream.ProcessAuthenticationAsync(Boolean, CancellationToken) + 0x6a
   at System.Net.Security.SslStream.AuthenticateAsClientAsync(SslClientAuthenticationOptions, CancellationToken) + 0x50
   at System.Net.Http.ConnectHelper.<EstablishSslConnectionAsync>d__2.MoveNext() + 0xc0
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.<EstablishSslConnectionAsync>d__2.MoveNext() + 0x413
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at System.Net.Http.HttpConnectionPool.<ConnectAsync>d__96.MoveNext() + 0xafe
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at System.Net.Http.HttpConnectionPool.<CreateHttp11ConnectionAsync>d__98.MoveNext() + 0x259
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at System.Net.Http.HttpConnectionPool.<AddHttp11ConnectionAsync>d__73.MoveNext() + 0x224
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at System.Threading.Tasks.TaskCompletionSourceWithCancellation`1.<WaitWithCancellationAsync>d__1.MoveNext() + 0x170
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at System.Net.Http.HttpConnectionPool.<GetHttp11ConnectionAsync>d__75.MoveNext() + 0x337
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Net.Http.HttpConnectionPool.<SendWithVersionDetectionAndRetryAsync>d__83.MoveNext() + 0x8e8
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at System.Net.Http.RedirectHandler.<SendAsync>d__4.MoveNext() + 0x1e2
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at System.Net.Http.HttpClient.<<SendAsync>g__Core|83_0>d.MoveNext() + 0x3e0
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at Program.<<Main>$>d__0.MoveNext() + 0x13a
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x20
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xb6
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x42
   at Program.<Main>(String[]) + 0x20
   at test!<BaseAddress>+0x6c311a

Is it a known limitation of the current version?

ModuleInitializer does not work

using System;
using System.Runtime.CompilerServices;

namespace Test
{
    class Program
    {
        public static int _counter = 0;
            
        
        public static void Main()
        {
            Console.WriteLine($"Hello world {++_counter}");
        }
		
	[ModuleInitializer]
	public static void Init()
	{
	     _counter = 999;
	}
    }
}

output:

Hello world 1

EDIT:
It does not work with NativeAOT.
So i opened the issue there: dotnet/runtimelab#1315

bflat != c#

First of all sry for putting this here, but I have no idea how to contact you otherwise.

I'm sure you know this but here it goes anyway. An equivalent of c# in musical theory is actually dflat not bflat. I presume
you knew this but still chose to use bflat as a name for your own reasons, but maybe you didn't...

I also think dflat would maybe be a better name not only for being equivalent to c# but also because there is already a
systems language D so Dflat would be a great word play since this is kind of a systems language/tooling ...

Anyways, just thought I should point it out. Thanks and good luck :)

Support for targeting MacOS.

I would like it if this can be used to build native things for MacOS without needing to self contain with the runtime (and as a consequence a ton of files that could and sometimes would need to go into the application bundle for a program even if it's a simple Avalonia application).

Handle module/external packaging with nuget

I love the idea of this project to compete with Golang, but I don't think there is a neat way to resolve external dependency problem. Unfortunately, this also mean you'd have to implement some kind of module support, just like Go Modules, which is a hot mess. In Golang you can just import from GitHub, but in .NET world most of us use nuget. More specifically, should we pull the nuget manifest every time we see one in the parent directory and link it this way?

Related: #1 but specifically targeting nuget

Implementation for 'System.Span`1'

Hello,
I am making an implementation for the ``System.Runtime.InteropServices.NativeMemory'' class but i need (what seems to be) a class constructor for 'System.Span`1', and i have no clue what it should do or what it needs to look like. I opened this so that anyone who knows about it can comment and leave suggestions.

F# support

I'm not using this issue to push the creator to support F#. This is for the F# community to figure out if this is something that any of us are interested in working on testing/implementing. Also to track what needs to be done or changed to get it working. I personally think the zero version could be very compelling for F#.

Considerations

  • What things do we expect to never work in zero
    • is that a dealbreaker or are there workarounds?
  • Since .net interop isn't needed in zero should we use rust style struct unions?
  • What subset of F# language features would give a usable experience?
  • How does interop work in zero?
    • How to use C/C++ ?
    • If OCaml interop is good and bidirectional it would allow for broader use of both F# and OCaml.
    • What kinds of inspirations from OCaml can we use for the zero implementation.

Support for arbitrary DllImport on Linux

Because we link the executable statically with no dependencies on target system's libc, it makes supporting dynamic loading annoying (MUSL that we link against really doesn't want to allow that). We basically can't call dlopen without weird and unportable workarounds (like https://github.com/pfalcon/foreign-dlopen).

I see a couple options:

  • Give up on static linking and depend on a libc. Libc will need to be specified when cross building (glibc/musl/whatever).
  • Use one of the hacks.

DllImport currently only works for things we link in statically (i.e. pretty much just the framework built-in DllImports).

Mac version?

Sorry to be that guy!

This sounds super promising, I love your philosophy. I'd be super interested if you ever made a macOS version of the compiler :)

References do not work

Executing task: d:\Programs\bflat\bflat.exe build -o d:\Unlinked\repos\PETest\Program.exe --reference d:\Unlinked\repos\PETest\refs\PeNet.dll d:\Unlinked\repos\PETest\refs\PeNet.Asn1.dll --no-reflection --no-stacktrace-data --no-globalization --no-exception-messages --optimize-space d:\Unlinked\repos\PETest\Program.cs <

I tried different ways, commas and what not, no matter it always tries to read them as source files.

new Option<string[]>(new string[] { "-r", "--reference" },
            "Additional .NET assemblies to include")
        {
            ArgumentHelpName = "file list"
        };

It works if I specify single file but then if I have unrelated references it would fail at build.

Is it possible to exclude Garbage Collector?

I think I saw a POC once that took out the garbage collector. This could be useful for one of our applications that does very little and I think has no allocations once running. Of course I may be wrong on that if some internals of .net would always be generating allocations (instrumentation?).

I mainly want to reduce the start-up time of the app, I don't know how much impact GC has on that.

Fails on non-ascii path

error: Unable to create file for E:\下载\bflat-0.0.4-windows-x64\test.obj: 在多字节的目标代码页中,没有此 Unicode 字符可以映射到的字符。
Error: Fail to initialize Native Object Writer
System.IO.IOException: Fail to initialize Native Object Writer
   at ILCompiler.DependencyAnalysis.ObjectWriter..ctor(String, NodeFactory, ObjectWritingOptions) + 0x227
   at ILCompiler.DependencyAnalysis.ObjectWriter.EmitObject(String, IReadOnlyCollection`1, NodeFactory, ObjectWritingOptions, IObjectDumper, Logger) + 0x8a
   at ILCompiler.RyuJitCompilation.CompileInternal(String, ObjectDumper) + 0xa8
   at ILCompiler.Compilation.ILCompiler.ICompilation.Compile(String, ObjectDumper) + 0x2c
   at Program.Run(String[]) + 0x2fe3
   at Program.Main(String[]) + 0x31

The error message seems to be No mapping for the Unicode character exists in the target multi-byte code page. And it works after I moving bflat itself to ascii only path. I'm ok with won't fix but I think it should be noted.

More documentation

Hi, thank you for this tool. It is amazing!

I was able to compile a large project thanks to the issue #7 where you specified the "-r" arg parameter.

Would be very useful to have a list of params that bflat accepts

How to reference a dotnet dll

Is there a way to reference a dll? I'm trying to build a project and when I do bflat build I get this

error CS0246: The type or namespace name 'Serilog' could not be found (are you missing a using directive or an assembly reference?)

Reflection support somehow limited ?

got a warning during compilation on this line (22) :

var assembly = Assembly.Load(memoryBytes);

message says :

D:\Program.cs(22): Trim analysis warning IL2026: Program.Main(String[]): Using method 'System.Reflection.Assembly.Load(Byte[])' which has 'RequiresUnreferencedCodeAttribute' can break functionality when trimming application code. Types and members the loaded assembly depends on might be removed.

and at runtime when i run the compiled output i got :

D:\bflat\Program.exe
Unhandled Exception: System.PlatformNotSupportedException: Operation is not supported on this platform.
   at Internal.Reflection.Execution.AssemblyBinderImplementation.Bind(Byte[], Byte[], AssemblyBindResult&, Exception&) + 0x39
   at System.Reflection.Runtime.Assemblies.RuntimeAssembly.GetRuntimeAssemblyFromByteArray(Byte[], Byte[]) + 0x56
   at Program.Main(String[]) + 0x5f
   at Program!<BaseAddress>+0x2d7bbf

`Error: IO_PathNotFound_Path, /usr/local/bin/ref` when building hello world sample from README

This seems like a pretty cool project! I wanted to try it out, so I downloaded the latest release and put it in /usr/local/bin because that directory was already on my path. That's where I put most binaries I download that I want to run, that I don't plan on upgrading over time.

My bflat file:

> which bflat
/usr/local/bin/bflat
> file $(which bflat)
/usr/local/bin/bflat: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, stripped
> bflat -v
7.0.1

My hello.cs file:

System.Console.WriteLine("Hello World!");

Output from bflat build hello.cs:

Error: IO_PathNotFound_Path, /usr/local/bin/ref
System.IO.DirectoryNotFoundException: IO_PathNotFound_Path, /usr/local/bin/ref
   at System.IO.Enumeration.FileSystemEnumerator`1.CreateDirectoryHandle(String, Boolean) + 0xa8
   at System.IO.Enumeration.FileSystemEnumerator`1.Init() + 0x1c
   at System.IO.Enumeration.FileSystemEnumerable`1..ctor(String, FileSystemEnumerable`1.FindTransform, EnumerationOptions, Boolean) + 0x89
   at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String, String, EnumerationOptions) + 0x97
   at System.IO.Directory.InternalEnumeratePaths(String, String, SearchTarget, EnumerationOptions) + 0x77
   at System.IO.Directory.GetFiles(String, String, EnumerationOptions) + 0x38
   at CommonOptions.GetReferencePaths(String[], StandardLibType) + 0xc8
   at BuildCommand.Handle(ParseResult) + 0x181
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext() + 0x10b
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xc2
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseErrorReporting>b__0>d.MoveNext() + 0xfd
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xc2
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext() + 0xbd
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xc2
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass23_0.<<UseVersionOption>b__0>d.MoveNext() + 0x1c0
--- End of stack trace from previous location ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() + 0x1c
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task) + 0xc2
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task) + 0x44
   at System.CommandLine.Invocation.InvocationPipeline.<Invoke>g__FullInvocationChain|3_0(InvocationContext) + 0x9a
   at Program.Main(String[]) + 0x20b

System info:

> lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.1 LTS
Release:        22.04
Codename:       jammy

Dllimport behavior

I was wondering, how does bflat work with additional native and managed dlls?
would the managed dlls be "included" in the created executable?
will the native dlls be used by the exe?
would it be possible to, somehow, include native code (compiled c++) directly in the generated executable?

Inline assembly?

A question i have, do you guys ever plan to implement inline assembly for UEFI bare metal programs? doing osdev with this would be a dream

Support for SQL server (System.Data.SqlClient)

Hi,

I have a small program that accesses a MS SQLserver database. When compiling with bflat I get the following error "The type name 'SqlConnection' could not be found in the namespace 'System.Data.SqlClient'. This type has been forwarded to assembly 'System.Data.SqlClient, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.".
The reference is there (see attachment), so I don't understand what is going wrong.

BFlat_error

How to specify C# lang version?

My project compiles well with Dotnet compiler, but errors reported with bflat. I don't see any arg to specify which c# version BFlat currently uses or to alter it.
Is this a big issue for source compatibility?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.