Page MenuHomeFreeBSD

Porter's Handbook: deprecate use of -march=native
ClosedPublic

Authored by linimon on Jul 8 2019, 11:40 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 5, 1:59 AM
Unknown Object (File)
Feb 9 2024, 5:45 PM
Unknown Object (File)
Jan 21 2024, 2:27 PM
Unknown Object (File)
Jan 10 2024, 1:57 AM
Unknown Object (File)
Nov 18 2023, 10:56 AM
Unknown Object (File)
Nov 18 2023, 9:38 AM
Unknown Object (File)
Nov 18 2023, 2:02 AM
Unknown Object (File)
Nov 17 2023, 11:24 PM
Subscribers

Details

Summary

Some ports default to optimizing their builds for the machine they are built on. This should be off for the cluster.

This patch documents a new policy that it should be turned off by default, either by being deleted or by being put behind an option.

(I suppose one other approach would be to put it behind PACKAGE_BUILDING but that seems overkill to me.)

Diff Detail

Repository
rD FreeBSD doc repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

linimon retitled this revision from Porter's Handbook: deprecated use of -march=native to Porter's Handbook: deprecate use of -march=native.Jul 8 2019, 11:41 PM

Yes, please. These blind attempts to optimize software by passing some magic tuning options to the compiler create way more problems than they solve. Tiny fraction of software actually puts efforts in optimizing and testing their builds (math, science, or security-related number crunching), other 99% should just trust their compiler TDRT and respect system C[XX]FLAGS. For those programs, there would hardly be any measurable or practically meaningful improvements anyway.

As you added a list, maybe add another point about excluding -msse* extensions from any non amd64 arch as it limits where the software can run on i386, and it breaks on other architectures. (grep'ing for sse in the tree, it seems there also is -mfpmath=sse.)

In D20885#452740, @mat wrote:

As you added a list, maybe add another point about excluding -msse* extensions

I do intend to add more information to this section based on the rework I am doing to accomodate "powerpc64 no longer implies gcc by default". Fortunately most of those do not require a policy decision, but this one does, so I would like to address it separately. Thanks.

In D20885#452740, @mat wrote:

As you added a list, maybe add another point about excluding -msse* extensions ...

Right, and some more (like -mcpu, -mtune). For example, this is the real excerpt from such a broken Makefile (new version of games/doomlegacy) which I must fix:

ifdef ARCH
  # if does not have leading -march, -mcpu, -mtune, or similar.
  ifeq ($(filter -march% -mcpu% -mtune% -m%, $(strip $(ARCH))),)
    # Apply to most general architecture compiler flag.
    CFLAGS:=-march=$(ARCH)
    $(warning Using ARCH as: $(CFLAGS) )
  else
    # Looks like a complete switch, use it as is.
    CFLAGS:=$(ARCH)
  endif
endif

It works by accident on i386, and fails miserably on amd64. *facepalm*

We really need to increase awareness that doing this is a bad idea and can easily break things.

In D20885#452740, @mat wrote:

As you added a list, maybe add another point about excluding -msse* extensions

I do intend to add more information to this section based on the rework I am doing to accomodate "powerpc64 no longer implies gcc by default". Fortunately most of those do not require a policy decision, but this one does, so I would like to address it separately. Thanks.

Oh, then, yes.

en_US.ISO8859-1/books/porters-handbook/porting-dads/chapter.xml
617–618 ↗(On Diff #59557)

under a non default OPTION.

Right, and some more (like -mcpu, -mtune).

I agree that more need to be added to the list. This whole section needs more work. But I hope to get this change in first.

en_US.ISO8859-1/books/porters-handbook/porting-dads/chapter.xml
651 ↗(On Diff #59575)

There is no OPTION variable, I think it would be better as:

under an off-by-default option,
linimon edited the summary of this revision. (Show Details)

Incorporate feedback.

This revision is now accepted and ready to land.Aug 13 2019, 1:11 PM