Repository: conan-io/conan-center-index

Issue:
[package] libx264/20191217: Error when building on ARM / MAC M1
I've got an error when trying to install OpenCV package. One of the dependencies is libx264 and is seems that an option is missing when building the package in macOS running with an ARM M1 microprocessor:

```
You specified a pre-ARMv6 or Thumb-1 CPU in your CFLAGS.
If you really want to run on such a CPU, configure with --disable-asm.
```

If I edit the recipe and add the `--disable-asm` option it works:

```
if self.settings.os == "Macos" and self.settings.arch == "armv8":
            # bitstream-a.S:29:18: error: unknown token in expression
            args.append("--extra-asflags=-arch arm64")
            args.append("--extra-ldflags=-arch arm64")
            args.append("--disable-asm")
```

### Package and Environment Details 
  * Package Name/Version: **libx/20191217**
  * Operating System+version: **macOs 12.0.1**
  * Compiler+version: **apple-clang 13.0**
  * Conan version: **conan 1.42.2**
  * Python version: **Python 3.9.8**

### Conan profile
```
[settings]
os=Macos
os_build=Macos
arch=armv8
arch_build=armv8
compiler=apple-clang
compiler.version=13.0
compiler.libcxx=libc++
build_type=Release
[options]
[conf]
[build_requires]
[env]
```

---
Should I create a PR for the change?


Discussion:
I think the ARM assembly code is works fine (.S files compile here), so this isn't desirable.  That error is from the 32-bit ARM section, not AARCH64 so maybe the --host triplet is wrong.  This is what I see (cross-compiling on an Intel Mac but it should be similar).  Note the --host=aarch64-apple-darwin

```
Configuration:
[settings]
arch=armv8
arch_build=armv8
build_type=Release
compiler=apple-clang
compiler.cppstd=11
compiler.libcxx=libc++
compiler.version=13.0
os=Macos
os.version=11.0
os_build=Macos
[options]
[build_requires]
[env]
libx264/20191217: Forced build from source
libx264/20191217 (test package): Installing package
Requirements
    libx264/20191217 from 'conancenter' - Cache
Packages
    libx264/20191217:ff8a0722914a67616b500f78e9a279f32dfcd3cc - Build

Cross-build from 'Macos:x86_64' to 'Macos:armv8'
Installing (downloading, building) binaries...
libx264/20191217: Copying sources to build folder
libx264/20191217: Building your package in /Users/gmeeker/.conan/data/libx264/20191217/_/_/build/ff8a0722914a67616b500f78e9a279f32dfcd3cc
libx264/20191217: Generator txt created conanbuildinfo.txt
libx264/20191217: Aggregating env generators
[HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK. 'fPIC' option found and apparently well managed
[HOOK - conan-center.py] pre_build(): [FPIC MANAGEMENT (KB-H007)] OK
libx264/20191217: Calling build()
libx264/20191217: WARN: Error running `configure --help`: Error 1 while executing source_subfolder/configure --help
libx264/20191217: Calling:
 > source_subfolder/configure '--bit-depth=all' '--disable-cli' '--prefix=/Users/gmeeker/.conan/data/libx264/20191217/_/_/package/ff8a0722914a67616b500f78e9a279f32dfcd3cc' '--enable-static' '--enable-pic' '--extra-asflags=-arch arm64' '--extra-ldflags=-arch arm64' --build=x86_64-apple-darwin --host=aarch64-apple-darwin
Unknown option --build=x86_64-apple-darwin, ignored
platform:      AARCH64
byte order:    little-endian
system:        MACOSX
cli:           no
libx264:       internal
shared:        no
static:        yes
asm:           yes
interlaced:    yes
avs:           no
lavf:          no
ffms:          no
mp4:           no
gpl:           yes
thread:        posix
opencl:        yes
filters:       crop select_every
lto:           no
debug:         no
gprof:         no
strip:         no
PIC:           yes
bit depth:     all
chroma format: all
```
Adding the following allows it to compile for me (on my M1):

```
             # bitstream-a.S:29:18: error: unknown token in expression
             args.append("--extra-asflags=-arch arm64")
             args.append("--extra-ldflags=-arch arm64")
+            args.append("--host=aarch64-apple-darwin")

         if self._with_nasm:
             # FIXME: get using user_build_info
```

I'm not sure if hard coding the host is the right solution here thought.
I'm running into the same issue trying to get conan to install opencv on a new machine.  The work-arounds mentioned above, where is this file that needs to be edited?
> I'm running into the same issue trying to get conan to install opencv on a new machine. The work-arounds mentioned above, where is this file that needs to be edited?

Here: https://github.com/conan-io/conan-center-index/blob/ba9b65b01d67a93d03f4bd90b1fa9f4e47b69012/recipes/libx264/all/conanfile.py#L98

If this is the right fix I am happy to post a PR. I was just waiting for someone more knowledgeable about autoconf and C++ build tool chains to confirm first.

Resolving patch:
diff --git a/recipes/libx264/all/conanfile.py b/recipes/libx264/all/conanfile.py
--- a/recipes/libx264/all/conanfile.py
+++ b/recipes/libx264/all/conanfile.py
@@ -96,6 +96,7 @@ def _configure_autotools(self):
             # bitstream-a.S:29:18: error: unknown token in expression
             args.append("--extra-asflags=-arch arm64")
             args.append("--extra-ldflags=-arch arm64")
+            args.append("--host=aarch64-apple-darwin")
 
         if self._with_nasm:
             # FIXME: get using user_build_info


Test patch: