Skip to content

Commit

Permalink
build-binutils.py: Fix error with x86-64-v{2,3,4} as value to '-m'
Browse files Browse the repository at this point in the history
These values are not valid '-mtune' values, so the build errors.

Do not add '-mtune' at all, unless one of these values has been
specified, in which case '-mtune=native' is a safe choice.

Closes: #255
Link: https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed Nov 30, 2023
1 parent 5c6f834 commit 6b42b6c
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions build-binutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
'--march',
metavar='ARCH',
help='''
Add -march=ARCH and -mtune=ARCH to CFLAGS to optimize the toolchain for the target
host processor.
Add -march=ARCH to CFLAGS to optimize the toolchain for the processor that it will be
running on.
''',
type=str)
parser.add_argument('--show-build-commands',
Expand Down Expand Up @@ -120,7 +120,14 @@
builder.folders.install = Path(args.install_folder).resolve()
builder.folders.source = bsm.location
if args.march:
builder.cflags += [f"-march={args.march}", f"-mtune={args.march}"]
builder.cflags.append(f"-march={args.march}")
# -march implies -mtune except for x86-64-v{2,3,4}, which are
# documented to imply -mtune=generic. If the user has requested one
# of these values, it is a safe assumption they only care about
# running on their machine, so add -mtune=native to further
# optimize the toolchain for their machine.
if 'x86-64-v' in args.march:
builder.cflags.append('-mtune=native')
builder.show_commands = args.show_build_commands
builder.build()
else:
Expand Down

0 comments on commit 6b42b6c

Please sign in to comment.