Autotools plugin cannot create executable

Hi,

Since yesterday building MicroK8s is failing with the following error:

Pulling libnftnl                                     
Downloading 'libnftnl-1.0.9.tar.bz2'[===================================================================================================================================================================================================================] 100%
'iptables' has dependencies that need to be staged: libnftnl
Skipping pull libnftnl (already ran)                      
Building libnftnl                                                
./configure --prefix=                                  
checking build system type... Segmentation fault (core dumped)
Warning: creating insecure temp directory        
Segmentation fault (core dumped)                      
Segmentation fault (core dumped)                            
Segmentation fault (core dumped)                              
Segmentation fault (core dumped)                               
x86_64-pc-linux-gnu                           
checking host system type... x86_64-pc-linux-gnu    
checking for gcc... gcc                 
checking whether the C compiler works... no      
configure: error: in `/root/build_microk8s/parts/libnftnl/build':
configure: error: C compiler cannot create executables  
See `config.log' for more details                                
Failed to run './configure --prefix=' for 'libnftnl': Exited with code 77.
Verify that the part is using the correct parameters and try again.

As you can see in the snapcraft.yaml we build libnftnl with the autotools plugin. Has anything changed?

Thanks

This is not MicroK8s specific. Was able to reproduce with the dosbox yaml in classic confinement. Bug opened: https://bugs.launchpad.net/snapcraft/+bug/1817300

Thanks

I am having this issue with snapcraft 4.3, snapd 2.46.1 with core18 as the base. I’m on Ubuntu 20.04.

I didn’t transmit the error, but this is the stack. Trying to build apache:

Traceback (most recent call last):
  File "/snap/snapcraft/5472/bin/snapcraft", line 33, in <module>
    sys.exit(load_entry_point('snapcraft==4.3', 'console_scripts', 'snapcraft')())
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/cli/_command.py", line 88, in invoke
    return super().invoke(ctx)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 354, in snap
    _execute(steps.PRIME, parts=tuple(), pack_project=True, output=output, **kwargs)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/cli/lifecycle.py", line 92, in _execute
    lifecycle.execute(step, project_config, parts)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 137, in execute
    executor.run(step, part_names)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 191, in run
    self._handle_step(part_names, part, step, current_step, cli_config)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 205, in _handle_step
    getattr(self, "_run_{}".format(current_step.name))(part)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 258, in _run_build
    self._run_step(step=steps.BUILD, part=part, progress="Building")
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/lifecycle/_runner.py", line 325, in _run_step
    getattr(part, step.name)()
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 590, in build
    self._do_build()
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 685, in _do_build
    self._do_runner_step(steps.BUILD)
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/__init__.py", line 272, in _do_runner_step
    return getattr(self._runner, "{}".format(step.name))()
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 90, in build
    steps.BUILD,
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 171, in _run_scriptlet
    scriptlet_name, function_call.strip()
  File "/snap/snapcraft/5472/lib/python3.6/site-packages/snapcraft/internal/pluginhandler/_runner.py", line 227, in _handle_builtin_function
    function(**function_args)
  File "/root/project/snap/plugins/apache.py", line 45, in build
    cwd=self.builddir, shell=True)
  File "/snap/snapcraft/5472/usr/lib/python3.6/subprocess.py", line 311, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command './configure --prefix=/root/parts/apache/install --with-mpm=event --enable-modules=none --enable-mods-shared='headers proxy proxy_fcgi setenvif env rewrite mime dir authz_core unixd alias ssl socache_shmcb' ENABLED_DSO_MODULES='headers,proxy,proxy_fcgi,setenvif,env,rewrite,mime,dir,authz_core,unixd,alias,ssl,socache_shmcb'' returned non-zero exit status 77.

Apologize for the noise but I will answer my own question here in the hopes that it helps someone else: you can see this exact same symptom if you do not have the “g++” package installed as part of build-packages. There was an implicit dependency in this snapcraft yaml file that is imo, poor form.

But debugging that stage is ultimately what lead me to the solution.