Home Page

SDLMAME build failure on Ubuntu 18.10

Posted By: Procyon

SDLMAME build failure on Ubuntu 18.10 - 12/28/18 05:14 AM

Code
Compiling src/devices/bus/nubus/nubus_image.cpp...
In file included from /usr/include/string.h:494,
                 from ../../../../../src/emu/emucore.h:19,
                 from ../../../../../src/emu/emu.h:29:
In function ‘char* strcat(char*, const char*)’,
    inlined from ‘void nubus_image_device::file_cmd_w(address_space&, offs_t, u32, u32)’ at ../../../../../src/devices/bus/nubus/nubus_image.cpp:261:10:
/usr/include/x86_64-linux-gnu/bits/string_fortified.h:128:33: error: ‘char* __builtin___strcat_chk(char*, const char*, long unsigned int)’ accessing 129 or more bytes at offsets 1028 and 900 may overlap 1 byte at offset 1028 [-Werror=restrict]
   return __builtin___strcat_chk (__dest, __src, __bos (__dest));
          ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


I'm getting this whenever I try to build mame0205 from git, after a "make clean" with the latest gcc-8. Please advise on how to work around. Thank you.
Posted By: Vas Crabb

Re: SDLMAME build failure on Ubuntu 18.10 - 12/28/18 06:41 AM

We don't support building with the "fortify source" option enabled. It must be somehow enabled on your system via an environment variable. MAME is not secure software, use it at your own risk.
Posted By: Procyon

Re: SDLMAME build failure on Ubuntu 18.10 - 12/28/18 01:42 PM

Thank you VC. I'm entirely unfamiliar with this option. I did some Googling around, and came up with a few things, but I'm at a loss as to how to implement the solutions I've found. One suggestion was to run:
Code
gcc -Q --help=target
which spat out a large list of options. The one that seemed relevant in this case was
Code
-mstack-protector-guard=    		tls
I have no idea unfortunately, how to switch that to disabled.

Alternatively, it seemed like I could stick
Code
-CFLAGS += "-fno-stack-protector"
into the Makefile. The problem for me is, MAME's Makefile is a little intimidating and I don't know where it's best to put that line (or if it can go anywhere as long as it's outside of some #if block?)

Sorry. I've been a dev for over 20 years, but I'm outside of my expertise here. Any help would be appreciated. Thanks very much.

EDIT: I just tried to build with
Code
make CFLAGS="-fno-stack-protector"
but no dice, it failed the exact same way. Confused...
Posted By: Vas Crabb

Re: SDLMAME build failure on Ubuntu 18.10 - 12/28/18 05:45 PM

I'm more familiar with Red Hat than Ubuntu, but to the best of my knowledge it's controlled by the _FORTIFY_SOURCE macro. Setting it to 1 enables basic checking, and setting it to 2 enables additional, stricter checks. It's set by default when building RPM packages. Do you have a CFLAGS or CXXFLAGS environment variable coming from somewhere causing this macro to be defined?

Alternatively, you could either disable warnings as errors (add NOWERROR=1 to your build options) or try adding something to ARCHOPTS to disable this "feature".
Posted By: Procyon

Re: SDLMAME build failure on Ubuntu 18.10 - 12/28/18 06:25 PM

OK, so I tried:

Code
make CFLAGS='-D_FORTIFY_SOURCE=0'


but this produced:

Code
GCC 8 detected
Precompiling src/emu/emu.h...
<command-line>: error: "_FORTIFY_SOURCE" redefined [-Werror]
<built-in>: note: this is the location of the previous definition
cc1plus: all warnings being treated as errors
make[2]: *** [precompile.make:299: ../../../../linux_gcc/obj/x64/Release/emu.h.gch] Error 1
make[1]: *** [Makefile:88: precompile] Error 2
make: *** [makefile:1270: linux_x64] Error 2


I'm gonna try it now with NOWERROR=1.
Posted By: Vas Crabb

Re: SDLMAME build failure on Ubuntu 18.10 - 12/28/18 07:40 PM

It seems Gentoo started this, applying patches to their GCC to force _FORTIFY_SOURCE to always be defined as 1. There's some discussion on MongoDB's tracker here: https://jira.mongodb.org/browse/SERVER-29982
You might be able to work around it with -U_FORTIFY_SOURCE to undefine it rather than trying to redefine it to zero.
Posted By: Procyon

Re: SDLMAME build failure on Ubuntu 18.10 - 12/28/18 07:56 PM

Thank you for finding that, that's interesting. "make NOWERROR=1" worked. Out of curiosity, I'm going to try -U_FORTIFY_SOURCE just to see what happens. I'll post the results when I find out.
Posted By: Procyon

Re: SDLMAME build failure on Ubuntu 18.10 - 12/28/18 08:46 PM

Code
make CFLAGS='-U_FORTIFY_SOURCE'


built mame64 successfully. I'll stuff that in a note so that I remember the next time smile Thanks again for all your help.
Posted By: mochamame

Re: SDLMAME build failure on Ubuntu 18.10 - 03/07/19 09:10 AM

I'm trying to compile Mame 0.179 on a 64 bit platform under Ubuntu 18.10. I'm trying to do this so I can use it with QMC2.

The above information was very helpful however I'm getting some other errors during the compilation process:

Code
Compiling src/mame/drivers/caswin.cpp...
../../../../../src/mame/drivers/z88.cpp: In member function ‘void z88_state::bankswitch_update(int, uint16_t, int)’:
../../../../../src/mame/drivers/z88.cpp:62:20: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 2 [-Werror=format-overflow=]
  sprintf(bank_tag, "bank%d", bank + 2);
                    ^~~~~~~~
../../../../../src/mame/drivers/z88.cpp:62:20: note: directive argument in the range [-2147483646, 2147483647]
../../../../../src/mame/drivers/z88.cpp:62:9: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 6
  sprintf(bank_tag, "bank%d", bank + 2);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [acorn.make:425: ../../../../linux_gcc/obj/x64/Release/src/mame/drivers/z88.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Compiling src/mame/video/arcadia.cpp...
../../../../../src/mame/machine/apple2.cpp: In member function ‘void apple2_state::apple2_update_memory()’:
../../../../../src/mame/machine/apple2.cpp:190:19: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=]
     sprintf(wbank,"bank%d",bank+1);
                   ^~~~~~~~
../../../../../src/mame/machine/apple2.cpp:190:19: note: directive argument in the range [-2147483647, 2147483647]
../../../../../src/mame/machine/apple2.cpp:190:12: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 10
     sprintf(wbank,"bank%d",bank+1);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../../../../../src/mame/drivers/nc.cpp: In member function ‘void nc_state::nc_refresh_memory_bank_config(int)’:
../../../../../src/mame/drivers/nc.cpp:306:16: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=]
  sprintf(bank1,"bank%d",bank+1);
                ^~~~~~~~
../../../../../src/mame/drivers/nc.cpp:306:16: note: directive argument in the range [-2147483647, 2147483647]
../../../../../src/mame/drivers/nc.cpp:306:9: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 10
  sprintf(bank1,"bank%d",bank+1);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../../../../../src/mame/drivers/nc.cpp:307:16: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=]
  sprintf(bank5,"bank%d",bank+5);
                ^~~~~~~~
../../../../../src/mame/drivers/nc.cpp:307:16: note: directive argument in the range [-2147483643, 2147483647]
../../../../../src/mame/drivers/nc.cpp:307:9: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 10
  sprintf(bank5,"bank%d",bank+5);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Compiling src/mame/drivers/big10.cpp...
Compiling src/mame/drivers/forte2.cpp...
Compiling src/mame/drivers/msx.cpp...
Compiling src/mame/drivers/pengadvb.cpp...
../../../../../src/mame/drivers/atom.cpp: In member function ‘void atom_state::motor_w(int)’:
../../../../../src/mame/drivers/atom.cpp:607:20: error: ‘sprintf’ writing a terminating nul past the end of the destination [-Werror=format-overflow=]
   sprintf(devname, "%d", i);
                    ^~~~
../../../../../src/mame/drivers/atom.cpp:607:10: note: ‘sprintf’ output 2 bytes into a destination of size 1
   sprintf(devname, "%d", i);
   ~~~~~~~^~~~~~~~~~~~~~~~~~


Looks like some kind of format overflow? Any ideas how to fix this?

Thanks!
Posted By: Tafoid

Re: SDLMAME build failure on Ubuntu 18.10 - 03/07/19 09:15 AM

Originally Posted by mochamame
I'm trying to compile Mame 0.179 on a 64 bit platform under Ubuntu 18.10. I'm trying to do this so I can use it with QMC2.

The above information was very helpful however I'm getting some other errors during the compilation process:

Code
Compiling src/mame/drivers/caswin.cpp...
../../../../../src/mame/drivers/z88.cpp: In member function ‘void z88_state::bankswitch_update(int, uint16_t, int)’:
../../../../../src/mame/drivers/z88.cpp:62:20: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 2 [-Werror=format-overflow=]
  sprintf(bank_tag, "bank%d", bank + 2);
                    ^~~~~~~~
../../../../../src/mame/drivers/z88.cpp:62:20: note: directive argument in the range [-2147483646, 2147483647]
../../../../../src/mame/drivers/z88.cpp:62:9: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 6
  sprintf(bank_tag, "bank%d", bank + 2);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [acorn.make:425: ../../../../linux_gcc/obj/x64/Release/src/mame/drivers/z88.o] Error 1
make[2]: *** Waiting for unfinished jobs....
Compiling src/mame/video/arcadia.cpp...
../../../../../src/mame/machine/apple2.cpp: In member function ‘void apple2_state::apple2_update_memory()’:
../../../../../src/mame/machine/apple2.cpp:190:19: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=]
     sprintf(wbank,"bank%d",bank+1);
                   ^~~~~~~~
../../../../../src/mame/machine/apple2.cpp:190:19: note: directive argument in the range [-2147483647, 2147483647]
../../../../../src/mame/machine/apple2.cpp:190:12: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 10
     sprintf(wbank,"bank%d",bank+1);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../../../../../src/mame/drivers/nc.cpp: In member function ‘void nc_state::nc_refresh_memory_bank_config(int)’:
../../../../../src/mame/drivers/nc.cpp:306:16: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=]
  sprintf(bank1,"bank%d",bank+1);
                ^~~~~~~~
../../../../../src/mame/drivers/nc.cpp:306:16: note: directive argument in the range [-2147483647, 2147483647]
../../../../../src/mame/drivers/nc.cpp:306:9: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 10
  sprintf(bank1,"bank%d",bank+1);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
../../../../../src/mame/drivers/nc.cpp:307:16: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 6 [-Werror=format-overflow=]
  sprintf(bank5,"bank%d",bank+5);
                ^~~~~~~~
../../../../../src/mame/drivers/nc.cpp:307:16: note: directive argument in the range [-2147483643, 2147483647]
../../../../../src/mame/drivers/nc.cpp:307:9: note: ‘sprintf’ output between 6 and 16 bytes into a destination of size 10
  sprintf(bank5,"bank%d",bank+5);
  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Compiling src/mame/drivers/big10.cpp...
Compiling src/mame/drivers/forte2.cpp...
Compiling src/mame/drivers/msx.cpp...
Compiling src/mame/drivers/pengadvb.cpp...
../../../../../src/mame/drivers/atom.cpp: In member function ‘void atom_state::motor_w(int)’:
../../../../../src/mame/drivers/atom.cpp:607:20: error: ‘sprintf’ writing a terminating nul past the end of the destination [-Werror=format-overflow=]
   sprintf(devname, "%d", i);
                    ^~~~
../../../../../src/mame/drivers/atom.cpp:607:10: note: ‘sprintf’ output 2 bytes into a destination of size 1
   sprintf(devname, "%d", i);
   ~~~~~~~^~~~~~~~~~~~~~~~~~


Looks like some kind of format overflow? Any ideas how to fix this?

Thanks!


I could be wrong but I see -Werror which can usually be counteracted by adding NOWERROR=1 in your make string. Give that a try.

Posted By: mochamame

Re: SDLMAME build failure on Ubuntu 18.10 - 03/08/19 06:09 AM

Quote
I could be wrong but I see -Werror which can usually be counteracted by adding NOWERROR=1 in your make string. Give that a try.



That's funny because I thought I tried that but I guess I didn't do it correctly. It seems to have worked and resulted in a ~208 MB mame64 binary getting built. I also had to declare QT_SELECT, this is on an 8 core machine. Xubuntu 18.10 with gcc 8.2.0.

Code
$ export QT_SELECT=qt5
$ make -j9 CFLAGS='-U_FORTIFY_SOURCE' NOWERROR=1


Thanks.
© 2019 Forums