UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Compiling Rust code on UT

    Scheduled Pinned Locked Moved Other Projects
    15 Posts 5 Posters 1.4k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
      Reply
      • Reply as topic
      Log in to reply
      This topic has been deleted. Only users with topic management privileges can see it.
      • dobeyD Offline
        dobey @Giiba
        last edited by

        @Giiba No, you can use the main terminal app instead if you're only using CLI tools in the container. See https://docs.ubports.com/en/latest/userguide/dailyuse/libertine.html#shell-access

        M D 2 Replies Last reply Reply Quote 2
        • M Offline
          mirroronthewall @dobey
          last edited by

          @dobey So, some tools can be installed and contained in the container, but it can be accessed from the normal UT terminal app?

          And, instead OP was trying to either directly install the tools to the terminal app (outside of a container), or install a terminal emulator inside a Libertine container and then use the tools within that (like a terminal within a terminal)?

          arubislanderA 1 Reply Last reply Reply Quote 0
          • arubislanderA Offline
            arubislander @mirroronthewall
            last edited by

            @mirroronthewall
            Your understanding is correct

            πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
            Happily running Ubuntu Touch
            Google Pixel 3a (20.04 DEV)
            JingPad (24.04 preview)
            Meizu Pro 5 (16.04 DEV)

            1 Reply Last reply Reply Quote 1
            • D Online
              doniks @dobey
              last edited by

              @dobey said in Compiling Rust code on UT:

              @Giiba No, you can use the main terminal app instead if you're only using CLI tools in the container. See https://docs.ubports.com/en/latest/userguide/dailyuse/libertine.html#shell-access

              Now that we talk about this, I'm thinking ... Why not append the bin folders from the libertine container to the PATH variable ... That would be even easier and more seemless to use the cli tools that are installed in the container than the shell access from the docs ... Any downsides/risks?

              dobeyD 1 Reply Last reply Reply Quote 0
              • arubislanderA Offline
                arubislander
                last edited by

                That would only work for statically compiled executables. Or possibly also for executables that only depend on libraries that happen to be installed on the host system. It would not work for executables that make use of libraries that are installed in the container, but not available outside the container, or have different versions.

                πŸ‡¦πŸ‡Ό πŸ‡³πŸ‡± πŸ‡ΊπŸ‡Έ πŸ‡ͺπŸ‡Έ
                Happily running Ubuntu Touch
                Google Pixel 3a (20.04 DEV)
                JingPad (24.04 preview)
                Meizu Pro 5 (16.04 DEV)

                1 Reply Last reply Reply Quote 0
                • dobeyD Offline
                  dobey @doniks
                  last edited by

                  @doniks Things in the container need to be run from inside the container. Otherwise, they won't be contained.

                  1 Reply Last reply Reply Quote 1
                  • G Offline
                    Giiba
                    last edited by

                    Very interesting, learn something all the time.

                    So if I understand correctly I could create an alias for the gcc component in a container and then rustc could call it to do the linking thing when compiling? Would this work on files located outside the container (ie. my home directory ~/)?

                    Having now updated a couple of times since first doing this I can confirm that action does wreck-up the gcc install and it needs to be reinstalled after updates. However Rust's installation in ~/.cargo persists between updates just fine.

                    Now I just have to determine what exactly rustc is calling... doing some digging (with almost no understanding) I figured the 'linker' in question is 'ld' that comes with 'binutils', only to discover that they are already installed on the UT system.

                    Anyone know why the installed files don't work or what it is I would need to create an alias for? I'm going to try asking in some Rust discussion areas.

                    Because at this moment I can hack on gcc-multilib to the system image via apt with 60MB of space used, or install hundreds of MB of container and still not know what I need to alias...

                    dobeyD 1 Reply Last reply Reply Quote 0
                    • dobeyD Offline
                      dobey @Giiba
                      last edited by

                      @Giiba I'm not sure what you mean by alias here.

                      Simply create a container, and install the needed dependencies from apt using libertine-container-manager install-package for example, and then with libertine-launch -i <container_name> bash to get a shell in the container, you can do the rust install in ~/.cargo. After that, it should be usable just the same as when you are running in the host, once you open a terminal and run libertine-launch -i <container_name> bash to get the shell inside the container.

                      I don't recall which folders are bind mounted by default inside the container, but I think ~/Documents/ is one, so if you put all your source files under ~/Documents/code/ for example, you should be able to cd to there inside the container to compile things, while being able to transfer via MTP from a PC if that's what you're looking for. Otherwise, it'd probably be better to just use git or such as an intermediate for source transfer between multiple locations.

                      G 1 Reply Last reply Reply Quote 0
                      • G Offline
                        Giiba @dobey
                        last edited by

                        @dobey I was thinking of the alias feature of the container as detailed by the page you linked. But I understand how that is not necessary now.

                        I really am just playing with simple code, nothing requiring git or large transfers so as long as I can access a few small files in ~/Documents I am fine. I am just working through the book and it's examples which are all less than 50 lines of code.

                        I am continuing to be impressed with Seabass as it is a reasonable code editor neglecting the crazy backspace key behaviour (which is easy enough to avoid with the new selectiin features of the osk).

                        1 Reply Last reply Reply Quote 0
                        • G Offline
                          Giiba
                          last edited by

                          I set up a Libertine container, and installed gcc-multilib and rust with in and as expected everything ran and compiled within my ~/Documents folder
                          libertine_shell_speed_test.png

                          Interestingly, within the container the build of the 'hello world' program takes 3x longer than with gcc-multilib hacked onto the system:
                          system_hack_speed_test.png

                          1 Reply Last reply Reply Quote 1
                          • First post
                            Last post