Previous Thread
Next Thread
Print Thread
Page 1 of 2 1 2
Joined: Jan 2009
Posts: 68
P
Procyon Offline OP
Member
OP Offline
Member
P
Joined: Jan 2009
Posts: 68
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.

Joined: Feb 2004
Posts: 2,574
Likes: 276
Very Senior Member
Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,574
Likes: 276
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.

Joined: Jan 2009
Posts: 68
P
Procyon Offline OP
Member
OP Offline
Member
P
Joined: Jan 2009
Posts: 68
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...

Last edited by Procyon; 12/28/18 02:36 PM.
Joined: Feb 2004
Posts: 2,574
Likes: 276
Very Senior Member
Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,574
Likes: 276
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".

Joined: Jan 2009
Posts: 68
P
Procyon Offline OP
Member
OP Offline
Member
P
Joined: Jan 2009
Posts: 68
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.

Last edited by Procyon; 12/28/18 06:30 PM.
Joined: Feb 2004
Posts: 2,574
Likes: 276
Very Senior Member
Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,574
Likes: 276
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.

Joined: Jan 2009
Posts: 68
P
Procyon Offline OP
Member
OP Offline
Member
P
Joined: Jan 2009
Posts: 68
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.

Joined: Jan 2009
Posts: 68
P
Procyon Offline OP
Member
OP Offline
Member
P
Joined: Jan 2009
Posts: 68
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.

Joined: Mar 2009
Posts: 75
Likes: 2
M
Member
Offline
Member
M
Joined: Mar 2009
Posts: 75
Likes: 2
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!

Joined: Apr 2006
Posts: 737
Likes: 1
Senior Member
Offline
Senior Member
Joined: Apr 2006
Posts: 737
Likes: 1
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.


Joined: Mar 2009
Posts: 75
Likes: 2
M
Member
Offline
Member
M
Joined: Mar 2009
Posts: 75
Likes: 2
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.

Joined: Feb 2014
Posts: 1,075
Likes: 151
G
Very Senior Member
Offline
Very Senior Member
G
Joined: Feb 2014
Posts: 1,075
Likes: 151
I installed Ubuntu 19.04 on a new system and got the wonderful problems with compiling with FORTIFY_SOURCE.

So now I just create an alias in my .bashrc

alias mmake='make CFLAGS="-U_FORTIFY_SOURCE" '

and then just type mmake instead of make.

Joined: Jan 2009
Posts: 68
P
Procyon Offline OP
Member
OP Offline
Member
P
Joined: Jan 2009
Posts: 68
Sorry for the necrothread reply, but I thought it was worth mentioning that with 0.253's new compiler requirements, I was able to successfully build MAME in Ubuntu 22.10 with plain make and no additional compiler flags enabled.

Last edited by Procyon; 03/31/23 03:29 AM.
Joined: Feb 2004
Posts: 2,574
Likes: 276
Very Senior Member
Offline
Very Senior Member
Joined: Feb 2004
Posts: 2,574
Likes: 276
Originally Posted by Procyon
Sorry for the necrothread reply, but I thought it was worth mentioning that with 0.253's new compiler requirements, I was able to successfully build MAME in Ubuntu 22.10 with plain make and no additional compiler flags enabled.
I’d be surprised if the increase in required libc++ version affects anyone. Most of the people using libc++ are on macOS where it’s the default, and the minimum macOS version we recommend uses llvm/clang/libc++ 8. You’d need to be using a years-old Linux distro to have GNU libstdc++ older than 7, or even libc++ older than 7 (e.g. Fedora 29 from 2018 has GNU libstdc++ 8 and libc++ 7).

The changed requirements for Lua will just stop people from using USE_SYSTEM_LIB_LUA with impunity. If you take the default of compiling Lua along with MAME, it will keep working.

I just think it’s important to let people know when requirements change.

Page 1 of 2 1 2

Moderated by  R. Belmont 

Link Copied to Clipboard
Who's Online Now
1 members (Hydreigon), 47 guests, and 1 robot.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,308
Posts121,693
Members5,070
Most Online1,283
Dec 21st, 2022
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com