Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(compiler) Detect stdlib bundled with Perlang binaries #444

Merged
merged 1 commit into from
Mar 26, 2024

Conversation

perlun
Copy link
Collaborator

@perlun perlun commented Mar 26, 2024

This provides some of the groundwork for this, mentioned in https://github.com/perlang-org/ perlang/issues/406:

Distribute the (compiled) stdlib along with snapshot builds

The changes to the Makefile means that running make install will now install the stdlib into the expected location. The next step is to get the stdlib bundled with releases and release snapshots as well.

@perlun perlun added the experimental compilation Issues which are relevant when using experimental compilation label Mar 26, 2024
@perlun perlun added this to the 0.4.0 milestone Mar 26, 2024
@perlun perlun force-pushed the feature/detect-stdlib-binaries branch from 41583d4 to 4fe53e5 Compare March 26, 2024 20:10
FileName = "clang++",
// Make this explicit, since we have only tested this with a very specific clang version. Anything else is
// completely untested and not expected to work at the moment.
FileName = "clang++-14",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I deliberately made this a bit more strict. Let's see what error we get if you try to run this in a container without any clang-14 package installed btw...

Copy link
Collaborator Author

@perlun perlun Mar 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we go. With an added catch (SystemException e), and re-throwing this, we get something which is good enough for now (despite being a bit overly verbose):

root@ce9d3c51d947:/perlang# /home/per/.perlang/nightly/bin/perlang docs/examples/quickstart/pi.per
Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
 ---> System.ApplicationException: Failed running clang. Experimental compilation is only supported on Linux-based systems. If running a Debian/Ubuntu-based distribution, please ensure that the clang-14 package is installed since experimental compilation depends on it.
 ---> System.ComponentModel.Win32Exception (2): An error occurred trying to start process 'clang++-14' with working directory '/perlang'. No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo, String, String[], String[], String, Boolean, UInt32, UInt32, UInt32[], Int32& , Int32& , Int32& , Boolean, Boolean )
   at System.Diagnostics.Process.StartCore(ProcessStartInfo)
   at System.Diagnostics.Process.Start()
   at System.Diagnostics.Process.Start(ProcessStartInfo)
   at Perlang.Interpreter.Compiler.PerlangCompiler.Compile(String source, String path, CompilerFlags compilerFlags, ScanErrorHandler scanErrorHandler, ParseErrorHandler parseErrorHandler, NameResolutionErrorHandler nameResolutionErrorHandler, ValidationErrorHandler typeValidationErrorHandler, ValidationErrorHandler immutabilityValidationErrorHandler, CompilerWarningHandler compilerWarningHandler) in /home/per/git/perlang/src/Perlang.Interpreter/Compiler/PerlangCompiler.cs:line 607
   --- End of inner exception stack trace ---
   at Perlang.Interpreter.Compiler.PerlangCompiler.Compile(String source, String path, CompilerFlags compilerFlags, ScanErrorHandler scanErrorHandler, ParseErrorHandler parseErrorHandler, NameResolutionErrorHandler nameResolutionErrorHandler, ValidationErrorHandler typeValidationErrorHandler, ValidationErrorHandler immutabilityValidationErrorHandler, CompilerWarningHandler compilerWarningHandler) in /home/per/git/perlang/src/Perlang.Interpreter/Compiler/PerlangCompiler.cs:line 632
   at Perlang.Interpreter.Compiler.PerlangCompiler.CompileAndRun(String source, String path, CompilerFlags compilerFlags, ScanErrorHandler scanErrorHandler, ParseErrorHandler parseErrorHandler, NameResolutionErrorHandler nameResolutionErrorHandler, ValidationErrorHandler typeValidationErrorHandler, ValidationErrorHandler immutabilityValidationErrorHandler, CompilerWarningHandler compilerWarningHandler) in /home/per/git/perlang/src/Perlang.Interpreter/Compiler/PerlangCompiler.cs:line 221
   at Perlang.ConsoleApp.Program.CompileAndRun(String source, String path, CompilerWarningHandler compilerWarningHandler) in /home/per/git/perlang/src/Perlang.ConsoleApp/Program.cs:line 456
   at Perlang.ConsoleApp.Program.RunFile(String path) in /home/per/git/perlang/src/Perlang.ConsoleApp/Program.cs:line 344
   at Perlang.ConsoleApp.Program.<>c__DisplayClass13_0.<MainWithCustomConsole>b__4(ParseResult parseResult, IConsole _) in /home/per/git/perlang/src/Perlang.ConsoleApp/Program.cs:line 249
   at System.RuntimeMethodHandle.InvokeMethod(Object, Void**, Signature, Boolean)
   at System.Reflection.MethodInvoker.Invoke(Object, IntPtr*, BindingFlags)
   --- End of inner exception stack trace ---
   at System.Reflection.MethodInvoker.Invoke(Object, IntPtr*, BindingFlags)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.Invoke(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass12_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationPipeline.<Invoke>g__FullInvocationChain|3_0(InvocationContext)
   at Perlang.ConsoleApp.Program.MainWithCustomConsole(String[] args, IPerlangConsole console) in /home/per/git/perlang/src/Perlang.ConsoleApp/Program.cs:line 292
   at Perlang.ConsoleApp.Program.Main(String[] args) in /home/per/git/perlang/src/Perlang.ConsoleApp/Program.cs:line 108
Aborted (core dumped)

This provides some of the groundwork for this, mentioned in
#406:

> Distribute the (compiled) stdlib along with snapshot builds

The changes to the `Makefile` means that running `make install` will now
install the `stdlib` into the expected location. The next step is to get
the `stdlib` bundled with releases and release snapshots as well.
@perlun perlun force-pushed the feature/detect-stdlib-binaries branch from 4fe53e5 to fa1b8ae Compare March 26, 2024 20:31
@perlun perlun enabled auto-merge (squash) March 26, 2024 20:34
@perlun perlun merged commit e106542 into master Mar 26, 2024
14 checks passed
@perlun perlun deleted the feature/detect-stdlib-binaries branch March 26, 2024 20:35
@perlun perlun mentioned this pull request Mar 30, 2024
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
experimental compilation Issues which are relevant when using experimental compilation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant