Skip to content

Comments

julec: init at 0.1.3#379891

Merged
philiptaron merged 4 commits intoNixOS:masterfrom
koibtw:julec
Mar 19, 2025
Merged

julec: init at 0.1.3#379891
philiptaron merged 4 commits intoNixOS:masterfrom
koibtw:julec

Conversation

@koibtw
Copy link
Member

@koibtw koibtw commented Feb 6, 2025

Jule is a general-purpose programming language focusing on systems programming. It aims to be fast, efficient and safe. Jule has its own set of goals and ideas that make it original.
Website: jule.dev

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` label Feb 6, 2025
@nix-owners nix-owners bot requested a review from philiptaron February 6, 2025 19:07
@NixOSInfra NixOSInfra added the 12.first-time contribution This PR is the author's first one; please be gentle! label Feb 6, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Feb 6, 2025
@koibtw koibtw changed the title julec: init at 0.1.2 julec: init at 0.1.3 Feb 7, 2025
@ethancedwards8
Copy link
Member

Also, everything probably needs to be in by-name instead. Also, you probably want to split the two packages into their own files.

@koibtw
Copy link
Member Author

koibtw commented Feb 7, 2025

@ethancedwards8 Suggestions applied.
There is one package. The IR codes are necessary for building JuleC.

Also, everything probably needs to be in by-name instead.

What about development/compilers?

@koibtw koibtw requested a review from ethancedwards8 February 7, 2025 23:19
@ethancedwards8
Copy link
Member

@ethancedwards8 Suggestions applied. There is one package. The IR codes are necessary for building JuleC.

Also, everything probably needs to be in by-name instead.

What about development/compilers?

Not sure. good question. Probably best to leave it for someone more experienced than me to comment

@koibtw
Copy link
Member Author

koibtw commented Feb 8, 2025

Suggestions applied. I've moved the package to development/compilers.

@koibtw koibtw requested a review from ethancedwards8 February 8, 2025 16:14
@koibtw koibtw force-pushed the julec branch 3 times, most recently from 50058bd to 5091d8e Compare February 9, 2025 12:38
@wegank wegank added the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 15, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Feb 28, 2025
@koibtw
Copy link
Member Author

koibtw commented Feb 28, 2025

@ethancedwards8 @wegank conflicts resolved

@FliegendeWurst FliegendeWurst added the 8.has: package (new) This PR adds a new package label Mar 15, 2025
@ofborg ofborg bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 16, 2025
@ofborg ofborg bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Mar 16, 2025
@github-actions github-actions bot added 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. and removed 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Mar 16, 2025
koibtw and others added 3 commits March 16, 2025 02:55
Signed-off-by: Adam Perkowski <adas1per@protonmail.com>
Co-authored-by: Sebaguardian <sebaguardian13@gmail.com>
Signed-off-by: Adam Perkowski <adas1per@protonmail.com>
@philiptaron
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 379891


x86_64-linux

✅ 1 package built:
  • julec

@philiptaron
Copy link
Contributor

nixpkgs-review result

Generated using nixpkgs-review.

Command: nixpkgs-review pr 379891


x86_64-darwin

✅ 1 package built:
  • julec

@FliegendeWurst
Copy link
Member

Would suggest to change as below.

  1. abort should not be used, as it cannot be caught
  2. instead of specifying clang++, make the derivation work for other compilers too (use (julec.override { stdenv = clangStdenv; }) to get a clang-compiled version)
  3. correct platform list based on the if statement at the start
  4. other best practices
diff --git a/pkgs/by-name/ju/julec/package.nix b/pkgs/by-name/ju/julec/package.nix
index 50007c3a5f97..68457a72960a 100644
--- a/pkgs/by-name/ju/julec/package.nix
+++ b/pkgs/by-name/ju/julec/package.nix
@@ -2,7 +2,6 @@
   lib,
   stdenv,
   fetchFromGitHub,
-  clang,
 }:
 
 let
@@ -18,7 +17,7 @@ let
     else if stdenv.hostPlatform.system == "aarch64-darwin" then
       "darwin-arm64.cpp"
     else
-      abort "Unsupported platform: ${stdenv.hostPlatform.system}";
+      throw "Unsupported platform: ${stdenv.hostPlatform.system}";
 in
 stdenv.mkDerivation (finalAttrs: {
   pname = "julec";
@@ -35,13 +34,13 @@ stdenv.mkDerivation (finalAttrs: {
   irSrc = fetchFromGitHub {
     owner = "julelang";
     repo = "julec-ir";
+    # revision determined by: ?
     rev = "a274782922e4275c4a036d63acffd3369dbc382f";
     name = "jule-ir-${finalAttrs.version}";
     hash = "sha256-TXMSXTGTzZntPUhT6QTmn3nD2k855ZoAW9aQWyhrE8s=";
   };
 
   dontConfigure = true;
-  buildInputs = [ clang ];
 
   unpackPhase = ''
     runHook preUnpack
@@ -61,14 +60,14 @@ stdenv.mkDerivation (finalAttrs: {
 
     echo "Building ${finalAttrs.pname} v${finalAttrs.version} for ${stdenv.hostPlatform.system}..."
     mkdir -p bin
-    clang++ ir.cpp \
+    ${stdenv.cc.targetPrefix}c++ ir.cpp \
       --std=c++17 \
       -Wno-everything \
       -O3 \
       -flto \
       -DNDEBUG \
       -fomit-frame-pointer \
-      -o "bin/${finalAttrs.pname}"
+      -o "bin/${finalAttrs.meta.mainProgram}"
 
     runHook postBuild
   '';
@@ -81,13 +80,13 @@ stdenv.mkDerivation (finalAttrs: {
     cp -R api $out/lib/jule/api
     cp -R std $out/lib/jule/std
     cp -R bin $out/lib/jule/bin
-    ln -s $out/lib/jule/bin/${finalAttrs.pname} $out/bin/${finalAttrs.pname}
+    ln -s $out/lib/jule/bin/${finalAttrs.meta.mainProgram} $out/bin/${finalAttrs.meta.mainProgram}
 
     runHook postInstall
   '';
 
   meta = {
-    description = "The Jule Programming Language Compiler";
+    description = "Jule Programming Language Compiler";
     longDescription = ''
       Jule is an effective programming language designed to build efficient, fast, reliable and safe software while maintaining simplicity.
       It is a statically typed, compiled language with a syntax influenced by Go, Rust, and C++.
@@ -95,7 +94,13 @@ stdenv.mkDerivation (finalAttrs: {
     homepage = "https://jule.dev";
     changelog = "https://github.com/julelang/manual/releases/tag/jule${finalAttrs.version}";
     license = lib.licenses.bsd3;
-    platforms = lib.platforms.unix;
+    platforms = [
+      "x86_64-linux"
+      "aarch64-linux"
+      "i686-linux"
+      "x86_64-darwin"
+      "aarch64-darwin"
+    ];
     mainProgram = "julec";
     maintainers = with lib.maintainers; [
       adamperkowski

Co-authored-by: Sebaguardian <sebaguardian13@gmail.com>
Co-authored-by: FliegendeWurst <arne.keller@posteo.de>
Signed-off-by: Adam Perkowski <adas1per@protonmail.com>
@koibtw
Copy link
Member Author

koibtw commented Mar 18, 2025

@FliegendeWurst thanks, applied :)

@philiptaron
Copy link
Contributor

Since julec is a self-hosting compiler, doesn't this want to now re-compile the julec code using the newly built julec, then have that be the output of the derivation?

@koibtw
Copy link
Member Author

koibtw commented Mar 19, 2025

Since julec is a self-hosting compiler, doesn't this want to now re-compile the julec code using the newly built julec, then have that be the output of the derivation?

Yes, that'd be the case for implementations like julec-git for example but since julec would generate the same IR (with --opt L2) and compile it with the same -p flag (see here), it's just a waste of compiletime here.

Copy link
Contributor

@philiptaron philiptaron left a comment

Choose a reason for hiding this comment

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

If it's going to be bit-for-bit equivalent, that'd make an excellent test for future updates.

Maybe put it in passthru.tests.recompile-equivalence.

I built this a lot of different ways (julec, pkgsLLVM.julec, pkgsStatic.julec, pkgsCross.aarch64-multiplatform.julec) and it all compiled, though the errors the C++ compiler emitted made me think that some of the codegen might not be tuned appropriately. Not a concern when introducing a new compiler package though.

@philiptaron philiptaron dismissed ethancedwards8’s stale review March 19, 2025 12:34

Request completed.

@philiptaron philiptaron merged commit cd74270 into NixOS:master Mar 19, 2025
29 checks passed
@koibtw koibtw deleted the julec branch March 19, 2025 14:44
@koibtw
Copy link
Member Author

koibtw commented Mar 19, 2025

If it's going to be bit-for-bit equivalent, that'd make an excellent test for future updates.

Good idea. Unfortunately, it's not. If I had to guess it's due to the use of unsorted maps in IR generation. The Arch AUR packages use basic std tests transpiling for testing. This could be implemented here as well, although it doesn't really test much.

Also, clang is the preferred default backend compiler (see here). Is there a way to make it the default here or something like that?

@koibtw koibtw mentioned this pull request Mar 19, 2025
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. 12.first-time contribution This PR is the author's first one; please be gentle!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants