Repository: conda/conda-build

Issue:
"Unknown format" / "Failed to get_static_lib_exports" messages
### Checklist

- [X] I added a descriptive title
- [X] I searched open reports and couldn't find a duplicate

### What happened?

Given `meta.yaml`
```
package:
  name: demo
  version: 0.0.1
source:
  path: .
build:
  number: 0
  script: mkdir -pv $PREFIX/bin && $CC $CFLAGS hello.c -o $PREFIX/bin/hello
requirements:
  build:
    - make
    - {{ compiler('c') }}
about:
  license: OTHER
```
and `hello.c`
```
#include <stdio.h>

void main() {
  printf("hello, world\n");
}
```
`conda build .` emits many unexpected `Unknown format` and `Failed to get_static_lib_exports` messages -- the same number, in fact, so I think they're referring to the same thing. The `Unknown format` messages don't give any useful information, so I won't repeat them here, but the others I'm seeing in this case are
```
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib64/librpcsvc.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib64/libc_nonshared.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib64/libg.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/x86_64-conda-linux-gnu/sysroot/usr/lib64/libpthread_nonshared.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/libopcodes.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/libctf-nobfd.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/libbfd.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/libctf.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/gcc/x86_64-conda-linux-gnu/11.2.0/libgcc.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/gcc/x86_64-conda-linux-gnu/11.2.0/libiberty.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/gcc/x86_64-conda-linux-gnu/11.2.0/libgcov.a)
WARNING :: Failed to get_static_lib_exports(/home/maddenp/conda/conda-bld/demo_1678899249098/_build_env/lib/gcc/x86_64-conda-linux-gnu/11.2.0/libgcc_eh.a)
```
Thanks in advance for any guidance.

### Conda Info

```shell
active environment : base
    active env location : /home/maddenp/conda
            shell level : 1
       user config file : /home/maddenp/.condarc
 populated config files : 
          conda version : 23.1.0
    conda-build version : 3.23.3
         python version : 3.10.9.final.0
       virtual packages : __archspec=1=x86_64
                          __glibc=2.35=0
                          __linux=5.19.0=0
                          __unix=0=0
       base environment : /home/maddenp/conda  (writable)
      conda av data dir : /home/maddenp/conda/etc/conda
  conda av metadata url : None
           channel URLs : https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/maddenp/conda/pkgs
                          /home/maddenp/.conda/pkgs
       envs directories : /home/maddenp/conda/envs
                          /home/maddenp/.conda/envs
               platform : linux-64
             user-agent : conda/23.1.0 requests/2.28.1 CPython/3.10.9 Linux/5.19.0-35-generic ubuntu/22.04.2 glibc/2.35
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False
```


### Conda Config

```shell
<blank>
```


### Conda list

```shell
# packages in environment at /home/maddenp/conda:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main    defaults
_openmp_mutex             5.1                       1_gnu    defaults
backports                 1.1                pyhd3eb1b0_0    defaults
backports.functools_lru_cache 1.6.4              pyhd3eb1b0_0    defaults
backports.tempfile        1.0                pyhd3eb1b0_1    defaults
backports.weakref         1.0.post1                  py_1    defaults
beautifulsoup4            4.11.1          py310h06a4308_0    defaults
brotlipy                  0.7.0           py310h7f8727e_1002    defaults
bzip2                     1.0.8                h7b6447c_0    defaults
ca-certificates           2023.01.10           h06a4308_0    defaults
certifi                   2022.12.7       py310h06a4308_0    defaults
cffi                      1.15.1          py310h5eee18b_3    defaults
chardet                   4.0.0           py310h06a4308_1003    defaults
charset-normalizer        2.0.4              pyhd3eb1b0_0    defaults
click                     8.0.4           py310h06a4308_0    defaults
conda                     23.1.0          py310h06a4308_0    defaults
conda-build               3.23.3          py310h06a4308_0    defaults
conda-content-trust       0.1.3           py310h06a4308_0    defaults
conda-package-handling    2.0.2           py310h06a4308_0    defaults
conda-package-streaming   0.7.0           py310h06a4308_0    defaults
conda-verify              3.4.2                      py_1    defaults
cryptography              39.0.1          py310h9ce1e76_0    defaults
filelock                  3.9.0           py310h06a4308_0    defaults
future                    0.18.3          py310h06a4308_0    defaults
glob2                     0.7                pyhd3eb1b0_0    defaults
icu                       58.2                 he6710b0_3    defaults
idna                      3.4             py310h06a4308_0    defaults
jinja2                    3.1.2           py310h06a4308_0    defaults
jq                        1.6               h27cfd23_1000    defaults
ld_impl_linux-64          2.38                 h1181459_1    defaults
libarchive                3.6.2                hab531cd_0    defaults
libffi                    3.4.2                h6a678d5_6    defaults
libgcc-ng                 11.2.0               h1234567_1    defaults
libgomp                   11.2.0               h1234567_1    defaults
liblief                   0.12.3               h6a678d5_0    defaults
libstdcxx-ng              11.2.0               h1234567_1    defaults
libuuid                   1.41.5               h5eee18b_0    defaults
libxml2                   2.9.14               h74e7548_0    defaults
lz4-c                     1.9.4                h6a678d5_0    defaults
make                      4.2.1                h1bed415_1    defaults
markupsafe                2.1.1           py310h7f8727e_0    defaults
ncurses                   6.4                  h6a678d5_0    defaults
oniguruma                 6.9.7.1              h27cfd23_0    defaults
openssl                   1.1.1t               h7f8727e_0    defaults
patch                     2.7.6             h7b6447c_1001    defaults
patchelf                  0.17.2               h6a678d5_0    defaults
pip                       23.0.1          py310h06a4308_0    defaults
pkginfo                   1.8.3           py310h06a4308_0    defaults
pluggy                    1.0.0           py310h06a4308_1    defaults
psutil                    5.9.0           py310h5eee18b_0    defaults
py-lief                   0.12.3          py310h6a678d5_0    defaults
pycosat                   0.6.4           py310h5eee18b_0    defaults
pycparser                 2.21               pyhd3eb1b0_0    defaults
pyopenssl                 23.0.0          py310h06a4308_0    defaults
pysocks                   1.7.1           py310h06a4308_0    defaults
python                    3.10.9               h7a1cb2a_2    defaults
python-libarchive-c       2.9                pyhd3eb1b0_1    defaults
pytz                      2022.7          py310h06a4308_0    defaults
pyyaml                    6.0             py310h5eee18b_1    defaults
readline                  8.2                  h5eee18b_0    defaults
requests                  2.28.1          py310h06a4308_1    defaults
ripgrep                   13.0.0               hbdeaff8_0    defaults
ruamel.yaml               0.17.21         py310h5eee18b_0    defaults
ruamel.yaml.clib          0.2.6           py310h5eee18b_1    defaults
setuptools                65.6.3          py310h06a4308_0    defaults
six                       1.16.0             pyhd3eb1b0_1    defaults
soupsieve                 2.3.2.post1     py310h06a4308_0    defaults
sqlite                    3.41.1               h5eee18b_0    defaults
tk                        8.6.12               h1ccaba5_0    defaults
toml                      0.10.2             pyhd3eb1b0_0    defaults
toolz                     0.12.0          py310h06a4308_0    defaults
tqdm                      4.64.1          py310h06a4308_0    defaults
tzdata                    2022g                h04d1e81_0    defaults
urllib3                   1.26.14         py310h06a4308_0    defaults
wheel                     0.38.4          py310h06a4308_0    defaults
xz                        5.2.10               h5eee18b_1    defaults
yaml                      0.2.5                h7b6447c_0    defaults
zlib                      1.2.13               h5eee18b_0    defaults
zstandard                 0.19.0          py310h5eee18b_0    defaults
zstd                      1.5.2                ha4553b6_0    defaults
```


### Additional Context

_No response_


Discussion:
Thank you @maddenp for reporting this, I am facing the same issue :disappointed: 
After some exploration I think that I spotted the commit that caused this behavior: https://github.com/conda/conda-build/commit/ca174f86c741f1c4c313bd802577c34b62d6bee8
Before this commit, `enable_static` was set to `"false"` by default:
https://github.com/conda/conda-build/blob/26dfe8e795abc38ec68d33f760f17a344bb346b7/conda_build/config.py#L128-L129
But after this commit, `enable_static` is set to `enable_static_default` which is now `"true"` :confused: 
https://github.com/conda/conda-build/blob/ca174f86c741f1c4c313bd802577c34b62d6bee8/conda_build/config.py#L37
https://github.com/conda/conda-build/blob/ca174f86c741f1c4c313bd802577c34b62d6bee8/conda_build/config.py#L141-L142

This is for the `"Failed to get_static_lib_exports" messages` part!

Now, concerning the `"Unknown format"` message, I suspect the LIEF library
https://github.com/lief-project/LIEF/blob/f8f38b60757c0f0401df347de1266c0ecb88055b/src/Abstract/Parser.cpp#L88
which is called in [conda_build.os_utils.liefldd](https://github.com/conda/conda-build/blob/main/conda_build/os_utils/liefldd.py)

Still investigating, will try to come with  a PR soon :wink: 
Well, the `"Unknown format"` effectively comes from the LIEF library!
It occurs in the `ensure_binary` function
https://github.com/conda/conda-build/blob/f5051cb454686f109e93fb2031d37345dbf9dfff/conda_build/os_utils/liefldd.py#L56
In fact, the LIEF library doesn't crash when the format is unknown, but the message is printed :confounded::
For demonstration, you can create an empty file
```
touch /tmp/empty_file.txt
```
and after `conda install py-lief`, you can see:
```python
>>> import lief
>>> lief.parse("/tmp/empty_file.txt")
Unknown format
```
Even a fake file doesn't crash
```python
>>> lief.parse("fake_file")
Can't open 'fake_file'
Can't open 'fake_file'
Can't open 'fake_file'
Can't open 'fake_file'
Unknown format
```
OK!, `lief` logs can be shut down :tada: 
PR coming soon! :wink: 


Resolving patch:
diff --git a/conda_build/config.py b/conda_build/config.py
--- a/conda_build/config.py
+++ b/conda_build/config.py
@@ -50,7 +50,7 @@ def set_invocation_time():
 error_overlinking_default = "false"
 error_overdepending_default = "false"
 noarch_python_build_age_default = 0
-enable_static_default = "true"
+enable_static_default = "false"
 no_rewrite_stdout_env_default = "false"
 ignore_verify_codes_default = []
 exit_on_verify_error_default = False
diff --git a/conda_build/os_utils/liefldd.py b/conda_build/os_utils/liefldd.py
--- a/conda_build/os_utils/liefldd.py
+++ b/conda_build/os_utils/liefldd.py
@@ -29,6 +29,7 @@
 try:
     import lief
 
+    lief.logging.disable()
     have_lief = True
 except:
     pass


Test patch: