Skip to content

Conversation

@valdela1
Copy link
Contributor

No description provided.

@valdela1 valdela1 force-pushed the add_redhat_compilation branch from 7f269ef to 7045f8b Compare October 19, 2025 15:30
Makefile Outdated
CC ?= $(shell \
if command -v $(call to_uname_m,$(GOARCH))-linux-gnu-gcc >/dev/null 2>&1; then \
echo $(call to_uname_m,$(GOARCH))-linux-gnu-gcc; \
elif command -v $(call to_uname_m,$(GOARCH))-redhat-linux-gcc >/dev/null 2>&1; then \
Copy link
Member

Choose a reason for hiding this comment

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

If you are putting in conditional logic, can you add a final fall back to plain gcc, which is needed on e.g. openSUSE?

Copy link
Member

@afbjorklund afbjorklund Oct 19, 2025

Choose a reason for hiding this comment

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

As far as I can tell, the cross-compilers are called something like aarch64-suse-linux-gcc? We still need to fix gcc when not cross-compiling, though... (tested with opensuse/leap:latest container, and zypper)

Copy link
Member

Choose a reason for hiding this comment

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

We still need to fix gcc when not cross-compiling, though...

That's why I suggested it as a "final fallback" so it works for make native even when cross-gcc is not installed. Maybe it would need a comment too, and should be left for a separate PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will test compiling lima on opensuse leap 16

Copy link
Contributor Author

Choose a reason for hiding this comment

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

test@opensuse:~> lsb_release -a
LSB Version:    n/a
Distributor ID: openSUSE
Description:    openSUSE Leap 16.0
Release:        16.0
Codename:       n/a
test@opensuse:~> ls -lh /usr/bin/gcc /usr/bin/gcc-15 /usr/bin/x86_64-suse-linux-gcc*
lrwxrwxrwx. 1 root root    6 Mar 12  2025 /usr/bin/gcc -> gcc-15
-rwxr-xr-x. 2 root root 1.6M Jul 17 11:24 /usr/bin/gcc-15
-rwxr-xr-x. 2 root root 1.6M Jul 17 11:24 /usr/bin/x86_64-suse-linux-gcc-15

If I add a condition for just "gcc", compiling on opensuse leap 16.0 is OK. Do you want this new condition in this PR or in another ?

Copy link
Member

Choose a reason for hiding this comment

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

@valdela1 Looks like we have consensus that it will no do any harm, and can sometimes be useful (native compilation with no cross-gcc support installed), so let's add it to this PR! Thanks!

Copy link
Member

@afbjorklund afbjorklund Oct 20, 2025

Choose a reason for hiding this comment

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

I do get compile errors, if I don't set CC and try to build for GOARCH=arm64 (on an amd64 machine)

runtime/cgo
# runtime/cgo
gcc_arm64.S: Assembler messages:
gcc_arm64.S:30: Error: no such instruction: `stp x29,x30,[sp,'
gcc_arm64.S:34: Error: too many memory references for `mov'

Basically it is using the wrong assembler. So I need to use aarch64-linux-gnu-gcc and not just gcc

Copy link
Member

Choose a reason for hiding this comment

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

Native compilation should not require any cross-gcc, but I feel that that is a separate bug.

Adding support for RHEL and SUSE, in addition to the existing Ubuntu, is good enough here.

And falling back to gcc can be a workaround, but eventually it needs to fail - when cross-compiling.

Building for the local platform should never need any cross-gcc, that is something of a "bug" today...

Copy link
Member

@afbjorklund afbjorklund Oct 20, 2025

Choose a reason for hiding this comment

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

When my Make files get too complicated, I tend to hide the ugly bits in a shell wrapper. Maybe appropriate?

cross-cc.sh or something similar

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@valdela1 Looks like we have consensus that it will no do any harm, and can sometimes be useful (native compilation with no cross-gcc support installed), so let's add it to this PR! Thanks!

done with some modifications :)

@valdela1
Copy link
Contributor Author

With this modification, compiling is OK on each distribution fully updated as of today:

  • Fedora 42
  • CentOS Stream 10
  • RHEL 10
  • Almalinux 10
  • Rockylinux 10
  • Debian 13
  • Ubuntu 24.04

@afbjorklund
Copy link
Member

afbjorklund commented Oct 20, 2025

The thing to verify, is whether it can cross-compile on Linux.

# CC is required for cross-compiling on Linux.
CC = $(call to_uname_m,$(GOARCH))-linux-gnu-gcc

If not cross-compiling, we should not have to set $CC at all....

All of the variables should then have reasonable defaults?

GOOS
GOARCH
CC (or GOCC?)

But testing make native is also a good sanity test, in itself.

@AkihiroSuda AkihiroSuda added this to the v2.0.0 milestone Oct 20, 2025
@valdela1
Copy link
Contributor Author

To give a bit more explications with the last modifications:

  1. Use "CC :=" instead of "CC ?=" to ensure the correct compiler
    Without this change, CC use "cc" instead of x86_64-linux-gnu-gcc, x86_64-redhat-linux-gcc or gcc.

  2. Change order of condition, because of packages like "gcc-$ARCH-linux-gnu" on Fedora/RHEL

$ rpm -qf /usr/bin/x86_64-linux-gnu-gcc
gcc-x86_64-linux-gnu-15.2.1-1.fc42.x86_64

On Fedora/RHEL, there is a package named gcc-x86_64-linux-gnu, if installed you have this file:

$ ll /usr/bin/x86_64-linux-gnu-gcc
-rwxr-xr-x. 1 root root 1999712 13 août  02:00 /usr/bin/x86_64-linux-gnu-gcc

It's not the same as the one on Debian/Ubuntu and compilation will failed on Fedora/RHEL. I didn't find equivalent on Debian/Ubuntu, that's why I just change condition order.

@valdela1
Copy link
Contributor Author

With the last modifications, I reconfirm compiling is OK on each distribution fully updated as of today and also OpenSUSE 16.0.

@valdela1 valdela1 marked this pull request as ready for review October 20, 2025 12:48
@AkihiroSuda
Copy link
Member

Please squash the commits
https://lima-vm.io/docs/dev/git/#squashing-commits

well as openSUSE

Signed-off-by: Valentin Dela <valdela@netc.fr>
@valdela1 valdela1 force-pushed the add_redhat_compilation branch from a7544e1 to a5fc10e Compare October 20, 2025 13:50
@valdela1
Copy link
Contributor Author

Please squash the commits https://lima-vm.io/docs/dev/git/#squashing-commits

hello, done :)

Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@AkihiroSuda or @afbjorklund please merge if you approve as well!

Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks, fun to see that the Red Hat Linux brand still survives in Fedora 👀

@AkihiroSuda AkihiroSuda merged commit e426bf0 into lima-vm:master Oct 21, 2025
37 checks passed
CC = $(call to_uname_m,$(GOARCH))-linux-gnu-gcc
# On Debian, Ubuntu, and related distributions, compilers are named like x86_64-linux-gnu-gcc
# On Fedora, RHEL, and related distributions, the equivalent is x86_64-redhat-linux-gcc
# On openSUSE and as a generic fallback, gcc is used
Copy link
Member

Choose a reason for hiding this comment

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

nit: cc could be a better generic fallback

@valdela1 valdela1 deleted the add_redhat_compilation branch October 21, 2025 11:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants