-
Notifications
You must be signed in to change notification settings - Fork 717
add compilation support for Fedora, RHEL, and related distributions #4228
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
Conversation
7f269ef to
7045f8b
Compare
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 \ |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)
|
With this modification, compiling is OK on each distribution fully updated as of today:
|
|
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-gccIf not cross-compiling, we should not have to set $CC at all.... All of the variables should then have reasonable defaults? GOOS But testing |
|
To give a bit more explications with the last modifications:
On Fedora/RHEL, there is a package named gcc-x86_64-linux-gnu, if installed you have this file: 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. |
|
With the last modifications, I reconfirm compiling is OK on each distribution fully updated as of today and also OpenSUSE 16.0. |
|
Please squash the commits |
well as openSUSE Signed-off-by: Valentin Dela <valdela@netc.fr>
a7544e1 to
a5fc10e
Compare
hello, done :) |
There was a problem hiding this 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!
There was a problem hiding this 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 👀
| 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 |
There was a problem hiding this comment.
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
No description provided.