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

Translate arch into source directory when ARCH is set #2122

Merged
merged 1 commit into from
Jan 9, 2019

Conversation

jeromemarchand
Copy link
Contributor

When ARCH is not defined, bcc get the architecture from uname. It then
modifies it to get the name of arch directory in linux source.

When ARCH is defined however, it just copy it as is, without the
translation to the arch directory. If for instance ARCH is set to
x86_64, it tries to look into the include directory
build/arch/x86_64/, which doesn't exist.

It fixes the following issue:
$ echo $ARCH
x86_64
$ /usr/share/bcc/tools/bashreadline
In file included from :2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from /lib/modules/4.18.0-49.el8.x86_64/build/include/linux/types.h:6:
/lib/modules/4.18.0-49.el8.x86_64/build/include/uapi/linux/types.h:5:10: fatal error: 'asm/types.h' file
not found
^~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
File "/usr/share/bcc/tools/bashreadline", line 51, in
b = BPF(text=bpf_text)
File "/usr/lib/python3.6/site-packages/bcc/init.py", line 318, in init
raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text

When ARCH is not defined, bcc get the architecture from uname. It then
modifies it to get the name of arch directory in linux source.

When ARCH is defined however, it just copy it as is, without the
translation to the arch directory. If for instance ARCH is set to
x86_64, it tries to look into the include directory
build/arch/x86_64/, which doesn't exist.

It fixes the following issue:
$ echo $ARCH
x86_64
$ /usr/share/bcc/tools/bashreadline
In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from /lib/modules/4.18.0-49.el8.x86_64/build/include/linux/types.h:6:
/lib/modules/4.18.0-49.el8.x86_64/build/include/uapi/linux/types.h:5:10: fatal error: 'asm/types.h' file
      not found
         ^~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
  File "/usr/share/bcc/tools/bashreadline", line 51, in <module>
    b = BPF(text=bpf_text)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 318, in __init__
    raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text
@yonghong-song
Copy link
Collaborator

[buildbot, test this please]

2 similar comments
@yonghong-song
Copy link
Collaborator

[buildbot, test this please]

@yonghong-song
Copy link
Collaborator

[buildbot, test this please]

@yonghong-song yonghong-song merged commit 28949f1 into iovisor:master Jan 9, 2019
brendangregg pushed a commit to brendangregg/bcc that referenced this pull request Jan 11, 2019
When ARCH is not defined, bcc get the architecture from uname. It then
modifies it to get the name of arch directory in linux source.

When ARCH is defined however, it just copy it as is, without the
translation to the arch directory. If for instance ARCH is set to
x86_64, it tries to look into the include directory
build/arch/x86_64/, which doesn't exist.

It fixes the following issue:
$ echo $ARCH
x86_64
$ /usr/share/bcc/tools/bashreadline
In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from /lib/modules/4.18.0-49.el8.x86_64/build/include/linux/types.h:6:
/lib/modules/4.18.0-49.el8.x86_64/build/include/uapi/linux/types.h:5:10: fatal error: 'asm/types.h' file
      not found
         ^~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
  File "/usr/share/bcc/tools/bashreadline", line 51, in <module>
    b = BPF(text=bpf_text)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 318, in __init__
    raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text
10ne1 added a commit to 10ne1/bcc that referenced this pull request Mar 26, 2019
Commit 28949f1 ("Translate arch into source directory when ARCH is set")
moved $ARCH processing earlier in the function so $ARCH gets processed
by the the same logic which parses the uname_machine value.

This introduced two bugs breaking ARCH=arm64 cross-compilation:

1. The arch.compare(0, 3, "arm") test matches both $ARCH=arm and $ARCH=arm64
leading to builds which always include from "arch/arm/include" instead
of "arch/arm64/include".

2. The only way arch == arm64 is if $ARCH=aarch64. uname returns aarch64
but the rest of the compiler logic expects $ARCH=arm64.

This fixes the above bugs by moving the "aarch64" test earlier than
the "arm" test and also accepting ARCH=arm64.

Fixes: 28949f1 ("Translate arch into source directory when ARCH is set (iovisor#2122)")
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
yonghong-song pushed a commit that referenced this pull request Mar 26, 2019
Commit 28949f1 ("Translate arch into source directory when ARCH is set")
moved $ARCH processing earlier in the function so $ARCH gets processed
by the the same logic which parses the uname_machine value.

This introduced two bugs breaking ARCH=arm64 cross-compilation:

1. The arch.compare(0, 3, "arm") test matches both $ARCH=arm and $ARCH=arm64
leading to builds which always include from "arch/arm/include" instead
of "arch/arm64/include".

2. The only way arch == arm64 is if $ARCH=aarch64. uname returns aarch64
but the rest of the compiler logic expects $ARCH=arm64.

This fixes the above bugs by moving the "aarch64" test earlier than
the "arm" test and also accepting ARCH=arm64.

Fixes: 28949f1 ("Translate arch into source directory when ARCH is set (#2122)")
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
palexster pushed a commit to palexster/bcc that referenced this pull request Jul 7, 2019
When ARCH is not defined, bcc get the architecture from uname. It then
modifies it to get the name of arch directory in linux source.

When ARCH is defined however, it just copy it as is, without the
translation to the arch directory. If for instance ARCH is set to
x86_64, it tries to look into the include directory
build/arch/x86_64/, which doesn't exist.

It fixes the following issue:
$ echo $ARCH
x86_64
$ /usr/share/bcc/tools/bashreadline
In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from /lib/modules/4.18.0-49.el8.x86_64/build/include/linux/types.h:6:
/lib/modules/4.18.0-49.el8.x86_64/build/include/uapi/linux/types.h:5:10: fatal error: 'asm/types.h' file
      not found
         ^~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
  File "/usr/share/bcc/tools/bashreadline", line 51, in <module>
    b = BPF(text=bpf_text)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 318, in __init__
    raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text
palexster pushed a commit to palexster/bcc that referenced this pull request Jul 7, 2019
Commit 28949f1 ("Translate arch into source directory when ARCH is set")
moved $ARCH processing earlier in the function so $ARCH gets processed
by the the same logic which parses the uname_machine value.

This introduced two bugs breaking ARCH=arm64 cross-compilation:

1. The arch.compare(0, 3, "arm") test matches both $ARCH=arm and $ARCH=arm64
leading to builds which always include from "arch/arm/include" instead
of "arch/arm64/include".

2. The only way arch == arm64 is if $ARCH=aarch64. uname returns aarch64
but the rest of the compiler logic expects $ARCH=arm64.

This fixes the above bugs by moving the "aarch64" test earlier than
the "arm" test and also accepting ARCH=arm64.

Fixes: 28949f1 ("Translate arch into source directory when ARCH is set (iovisor#2122)")
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
@jeromemarchand jeromemarchand deleted the archenv branch August 5, 2019 16:02
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
When ARCH is not defined, bcc get the architecture from uname. It then
modifies it to get the name of arch directory in linux source.

When ARCH is defined however, it just copy it as is, without the
translation to the arch directory. If for instance ARCH is set to
x86_64, it tries to look into the include directory
build/arch/x86_64/, which doesn't exist.

It fixes the following issue:
$ echo $ARCH
x86_64
$ /usr/share/bcc/tools/bashreadline
In file included from <built-in>:2:
In file included from /virtual/include/bcc/bpf.h:12:
In file included from /lib/modules/4.18.0-49.el8.x86_64/build/include/linux/types.h:6:
/lib/modules/4.18.0-49.el8.x86_64/build/include/uapi/linux/types.h:5:10: fatal error: 'asm/types.h' file
      not found
         ^~~~~~~~~~~~~
1 error generated.
Traceback (most recent call last):
  File "/usr/share/bcc/tools/bashreadline", line 51, in <module>
    b = BPF(text=bpf_text)
  File "/usr/lib/python3.6/site-packages/bcc/__init__.py", line 318, in __init__
    raise Exception("Failed to compile BPF text")
Exception: Failed to compile BPF text
CrackerCat pushed a commit to CrackerCat/bcc that referenced this pull request Jul 31, 2024
Commit 28949f1 ("Translate arch into source directory when ARCH is set")
moved $ARCH processing earlier in the function so $ARCH gets processed
by the the same logic which parses the uname_machine value.

This introduced two bugs breaking ARCH=arm64 cross-compilation:

1. The arch.compare(0, 3, "arm") test matches both $ARCH=arm and $ARCH=arm64
leading to builds which always include from "arch/arm/include" instead
of "arch/arm64/include".

2. The only way arch == arm64 is if $ARCH=aarch64. uname returns aarch64
but the rest of the compiler logic expects $ARCH=arm64.

This fixes the above bugs by moving the "aarch64" test earlier than
the "arm" test and also accepting ARCH=arm64.

Fixes: 28949f1 ("Translate arch into source directory when ARCH is set (iovisor#2122)")
Signed-off-by: Adrian Ratiu <adrian.ratiu@collabora.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants