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

remove native nasm #6263

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

hgy59
Copy link
Contributor

@hgy59 hgy59 commented Oct 7, 2024

Description

  • remove native nasm, it is a prerequisite in the dev. environment since update to debian 12
  • remove native yasm
  • update related Makefiles

Fixes #

Affected Libraries

Direct dependencies

  • cross/dav1d
  • cross/ffmpeg*
  • cross/lame
  • cross/libaom
  • cross/libvpx
  • cross/openh264
  • cross/svt-av1
  • cross/x264
  • cross/x265

Further findings

  • cross/zstd

Affected Packages

By direct dependencies

  • ffmpeg*
  • chromaprint
  • comskip
  • tvheadend
  • imagemagick
  • mpd
  • rutorrent

Checklist

  • Build rule all-supported completed successfully
  • New installation of package completed successfully
  • Package upgrade completed successfully (Manually install the package again)
  • Package functionality was tested
  • Any needed documentation is updated/created

Type of change

  • Includes small framework changes

hgy59 added 5 commits October 7, 2024 21:55
- remove native nasm, it is a prerequisite in the dev. environment since update to debian 12
- remove native yasm
- update related Makefiles
- change affected packages to trigger build
@hgy59 hgy59 requested a review from th0ma7 October 9, 2024 19:05
Copy link
Contributor

@th0ma7 th0ma7 left a comment

Choose a reason for hiding this comment

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

Beside possible issue found with openh264 that your change brought to light, LGTM.

cross/openh264/Makefile Outdated Show resolved Hide resolved
- update cross/dav1d
- remove definitions for nasm, meson build completely auto detects nasm
- remove definitions for nasm, meson build completely auto detects nasm
- create optimized code
- cmake builds completely auto detect nasm
@hgy59
Copy link
Contributor Author

hgy59 commented Dec 17, 2024

Special NASM definitions for meson and cmake build systems are obsolete and removed now.
The auto configuration for nasm works as expected.

further analysis for gcc builds (spksrc.cross-cc.mk) is WIP.

- disable support for OLD_PPC_ARCHS
- build with assembler, except for PPC_ARCHS
- remove obsolete configure args
  --enable-pic is forced with --enable-shared
  --cross-prefix is not required
- remove definition of GNU_CONFIGURE and define --host
- simplify definition of gcc as assembler if not using x86asm
- define --as=auto to use yasmm (prefered over nasm)
- document why we don't define GNU_CONFIGRE
- remove concurring patch
- avoid duplicate definition of --disable-neon
ifeq ($(findstring $(ARCH),$(i686_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --target=x86-linux-gcc
# --as=auto: prefers yasm over nasm
CONFIGURE_ARGS += --as=auto
CONFIGURE_ARGS += --disable-sse4_1
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@th0ma7 can you remember why you disabled sse4_1 for intel archs?
it builds just fine without disabling it

Copy link
Contributor

Choose a reason for hiding this comment

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

This change comes from this PR: #6148
Specifically from this commit: c4c0d44

But I haven't left any descriptions as to why I disabled it? Maybe it failed on DSM6, again using gcc <= 4.9.x for that specific libvpx version (i.e 1.14.1)?

Looking a bit further this may have been a mistake from my part as SSE4.1 (Streaming SIMD Extensions 4.1) has nothing to do with newer AVX extensions and may have mixed them somehow. A bit more reading on it makes it that pretty much all "recent" intel based nas from synology (i.e. less than 10-12 years old) should support this extension...

I believe it is safe to remove that.

@hgy59
Copy link
Contributor Author

hgy59 commented Dec 20, 2024

@th0ma7 the libraries and *.mk files are ready for review.

On the ffmpeg* packages there is some pending work...

  1. OLD_PPC_ARCHS fail to build ffmpeg since 4.4.x (4.3.x are the last working releases, newer have issue with stdatomic)

  2. There are some conditional dependencies for alpine comcerto2k and monaco archs.

    example:

    ifeq ($(findstring $(ARCH),alpine comcerto2k monaco $(ARMv8_ARCHS) $(i686_ARCHS) $(x64_ARCHS)),$(ARCH))
    DEPENDS += cross/libaom
    CONFIGURE_ARGS += --enable-libaom
    endif
    

    Except for arch-comcerto2k-7.1 we do not build additional packages for alpine and monaco
    If we would build dedicated packages for alpine and monaco we would need to exclude those archs in the armv7 generic packages.
    Despite we have an option to exclude dedicated archs from generic ones with REMOVE_FROM_GENERIC_ARCHS, we cannot use github build to create and publish dedicated archs.
    And we never planned to created a single package for a list of dedicated archs...

@hgy59
Copy link
Contributor Author

hgy59 commented Dec 20, 2024

and the third issue is with cross/lame:

even we configure with --enable-asm (and configure finds /usr/bin/nasm) it does not use the assembler.

Comment on lines -29 to -35
CONFIGURE_ARGS += -Denable_asm=true

# Allow ASM on aarch64, disable on all others
else ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS)),$(ARCH))
CONFIGURE_ARGS += -Denable_asm=true
else
CONFIGURE_ARGS += -Denable_asm=false
Copy link
Contributor

Choose a reason for hiding this comment

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

nasm is only used for x86/x86_64, while for aarch64 it uses the gcc assembler (as). Considering the code above, you should have kept something such as:

ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS) $(i686_ARCHS) $(x64_ARCHS)),$(ARCH))
CONFIGURE_ARGS += -Denable_asm=true
else
CONFIGURE_ARGS += -Denable_asm=false
endif

While it probably builds ok, I recall code to fail on armv7 in multiple cases which led to enable assembly optimizations only on aarch64 and x86 archs. I would suggest keeping this ifeq else usecase (and maybe elsewhere, haven't looked at all the code changes).

EDIT: On another comment I realized that issues with as on armv7 related to gcc <= 4.9, rather suggesting:

include ../../mk/spksrc.common.mk

ifeq ($(findstring $(ARCH),$(ARMv8_ARCHS) $(i686_ARCHS) $(x64_ARCHS)),$(ARCH))
CONFIGURE_ARGS += -Denable_asm=true

# only enable `asm` on armv7 when using gcc > 4.9.* (i.e. DSM7+)
else if ($(findstring $(ARCH),$(ARMv7_ARCHS) $(ARMv7L_ARCHS)),$(ARCH))
ifeq ($(call version_lt, ${TC_GCC}, 5),1)
CONFIGURE_ARGS += -Denable_asm=true
endif
else
CONFIGURE_ARGS += -Denable_asm=false
endif

Comment on lines +61 to +65
NASM_BINARY = $(shell which nasm)
ifeq ($(NASM_BINARY),)
$(error nasm not found. Please intall NASM assembler)
endif
ENV += AS=$(NASM_BINARY)
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that test even needed? I did not bother with that for ffmpeg5-6-7, maybe worth either using it everywhere or I would suggest not at all.

ADDITIONAL_CXXFLAGS = -std=c++0x
endif

ifeq ($(findstring $(ARCH),$(ARMv7_ARCHS) $(ARMv7L_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --target=armv7-linux-gcc
CONFIGURE_ARGS += --disable-neon
Copy link
Contributor

Choose a reason for hiding this comment

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

Disabling of neon was done in this PR #5620
This was the comit: 6ad7f5f

So from the commit log it states disabling neon (i.e. which includes as optimizations) on armv7 when using a compiler <= 4.9, basically on dsm6. I suggest the following change:

include ../../mk/spksrc.common.mk

ifeq ($(findstring $(ARCH),$(ARMv7_ARCHS) $(ARMv7L_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --target=armv7-linux-gcc
ifeq ($(call version_lt, ${TC_GCC}, 5),1)
CONFIGURE_ARGS += --disable-neon
endif
endif

ifeq ($(findstring $(ARCH),$(i686_ARCHS)),$(ARCH))
CONFIGURE_ARGS += --target=x86-linux-gcc
# --as=auto: prefers yasm over nasm
CONFIGURE_ARGS += --as=auto
CONFIGURE_ARGS += --disable-sse4_1
Copy link
Contributor

Choose a reason for hiding this comment

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

This change comes from this PR: #6148
Specifically from this commit: c4c0d44

But I haven't left any descriptions as to why I disabled it? Maybe it failed on DSM6, again using gcc <= 4.9.x for that specific libvpx version (i.e 1.14.1)?

Looking a bit further this may have been a mistake from my part as SSE4.1 (Streaming SIMD Extensions 4.1) has nothing to do with newer AVX extensions and may have mixed them somehow. A bit more reading on it makes it that pretty much all "recent" intel based nas from synology (i.e. less than 10-12 years old) should support this extension...

I believe it is safe to remove that.

@@ -15,14 +15,10 @@ LICENSE = BSD
UNSUPPORTED_ARCHS = $(PPC_ARCHS)

CONFIGURE_ARGS += -Dtests=disabled
ADDITIONAL_CPPFLAGS = -O
Copy link
Contributor

Choose a reason for hiding this comment

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

Why? is it to diable optimizations (i.e. -O0)

Comment on lines +28 to +35
# Define x86asm or use gcc as assembler
ifeq ($(findstring $(ARCH),$(i686_ARCHS) $(x64_ARCHS)),$(ARCH))
NASM_BINARY = $(shell which nasm)
ifeq ($(NASM_BINARY),)
$(error nasm not found. Please install NASM assembler)
endif
ENV += AS=$(NASM_BINARY)
else
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly to ffmpeg, isn't this too much as nasm is always installed?
If anything, I'd rather have that test being done outside from individual cross but within the framework to avoid code duplication if feasible.

Comment on lines -117 to -124
ifeq ($(strip $(CMAKE_USE_NASM)),1)
ifeq ($(findstring $(ARCH),$(i686_ARCHS) $(x64_ARCHS)),$(ARCH))
@echo "# set assembly compiler" ; \
echo "set(ENABLE_ASSEMBLY $(ENABLE_ASSEMBLY))" ; \
echo "set(CMAKE_ASM_COMPILER $(CMAKE_ASM_COMPILER))" ; \
echo
endif
endif
Copy link
Contributor

Choose a reason for hiding this comment

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

This is rather interesting... indeed cmake should auto-detect nasm as being in default PATH.

@th0ma7
Copy link
Contributor

th0ma7 commented Dec 29, 2024

@th0ma7 the libraries and *.mk files are ready for review.

I did a first pass, overall looking good. However I believe it does require minor adjustments for armv7 with gcc <= 4.9.x pertaining to assembly optimizations (i.e. neon).

On the ffmpeg* packages there is some pending work...

  1. OLD_PPC_ARCHS fail to build ffmpeg since 4.4.x (4.3.x are the last working releases, newer have issue with stdatomic)

I would suggest removing OLD_PPC_ARCHS from all ffmpeg makefiles and declaring it as unsupported.

  1. There are some conditional dependencies for alpine comcerto2k and monaco archs.
    Except for arch-comcerto2k-7.1 we do not build additional packages for alpine and monaco
    If we would build dedicated packages for alpine and monaco we would need to exclude those archs in the armv7 generic packages.
    Despite we have an option to exclude dedicated archs from generic ones with REMOVE_FROM_GENERIC_ARCHS, we cannot use github build to create and publish dedicated archs.
    And we never planned to created a single package for a list of dedicated archs...

Wow, that brings me a while back... when I took over the ffmpeg maintenance (which I didn't new what I was up against), I thought we absolutely needed arch specific packages for acceleration purposes... Not totally wrong but unsustainable as we a) don't have the manpower to support that (and not sure of the benefits) and b) don't have the storage space to do so.

Honestly this can be cleaned-up, it's just crap left-over. Good catch thoughg 🤷

@th0ma7
Copy link
Contributor

th0ma7 commented Dec 30, 2024

and the third issue is with cross/lame:

even we configure with --enable-asm (and configure finds /usr/bin/nasm) it does not use the assembler.

I tried enabling the following options to check if nasm would be used somewhere, but nothing (btw, nevertless, mp3rtp could be enabled with the addition of bin/mp3rtp to the PLIST):

CONFIGURE_ARGS  = --enable-mp3rtp
CONFIGURE_ARGS += --enable-shared
CONFIGURE_ARGS += --enable-dynamic-frontends

Looking at arch linux and gentoo they both enable nasm...? Even default debian rules files enables it. btw lame-3.100/debian/rules uses the following:

                --with-fileio=sndfile \
                --enable-nasm \
                --with-pic \
                --disable-mp3x \
                --disable-mp3rtp \
                --disable-gtktest \
                --enable-dynamic-frontends \
                --enable-expopt=full

Tried them all, nothing shows up from a nasm usage ... So I tried compiling on the host to see what hapens, and it does enter into libmp3lame/i386 where the assembly files are but does nothing:

Making all in libmp3lame
make[2]: Entering directory '/home/spksrc/python-wheels4/spksrc/distrib/lame-3.100/libmp3lame'
Making all in i386 
make[3]: Entering directory '/home/spksrc/python-wheels4/spksrc/distrib/lame-3.100/libmp3lame/i386'
make[3]: Nothing to be done for 'all'.
make[3]: Leaving directory '/home/spksrc/python-wheels4/spksrc/distrib/lame-3.100/libmp3lame/i386'

Honestly, I don't believe it ever worked or I'm missing something?

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