public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/59672] New: Add -m16 support for x86
@ 2014-01-03 23:00 hpa at zytor dot com
  2014-01-03 23:03 ` [Bug target/59672] " pinskia at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: hpa at zytor dot com @ 2014-01-03 23:00 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

            Bug ID: 59672
           Summary: Add -m16 support for x86
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hpa at zytor dot com

It would be a very good thing to have an official way to generate 16-bit
binaries on x86 (i386), even if all that is provided is a command-line flag
that issues a .code16gcc assembly directive first in the generated assembly
file.

In the Linux kernel, we currently have to do a bunch of hacks to make sure that
gcc doesn't issue any instructions *before* the .code16gcc directive:

                   $(call cc-option, -fno-toplevel-reorder,\
                   $(call cc-option, -fno-unit-at-a-time)) \
                   $(call cc-option, -fno-stack-protector) \

... and the list is likely to grow, which is why providing an actually
supported compiler flag for this would be desirable.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
@ 2014-01-03 23:03 ` pinskia at gcc dot gnu.org
  2014-01-03 23:09 ` hpa at zytor dot com
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu.org @ 2014-01-03 23:03 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note GCC does not even support real 16bit code for x86.  So pretending GCC's
output is 16bit code is a joke.

Why can't you just write the 16bit binary support in assembly for the kernel?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
  2014-01-03 23:03 ` [Bug target/59672] " pinskia at gcc dot gnu.org
@ 2014-01-03 23:09 ` hpa at zytor dot com
  2014-01-04 23:29 ` steven at gcc dot gnu.org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hpa at zytor dot com @ 2014-01-03 23:09 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

--- Comment #2 from H. Peter Anvin <hpa at zytor dot com> ---
It is much cleaner to have it in C.  We converted the assembly code to C back
in 2007 and it has been much easier to maintain ever since.  It works fine,
thankyouverymuch; it isn't *optimal* 16-bit code, but it is real and valid
16-bit code and we use it as such.

Sure, optimization would be nice.  Do we care?  Not a lot.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
  2014-01-03 23:03 ` [Bug target/59672] " pinskia at gcc dot gnu.org
  2014-01-03 23:09 ` hpa at zytor dot com
@ 2014-01-04 23:29 ` steven at gcc dot gnu.org
  2014-01-04 23:32 ` hpa at zytor dot com
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: steven at gcc dot gnu.org @ 2014-01-04 23:29 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

Steven Bosscher <steven at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Target|                            |i386-*-*
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2014-01-04
     Ever confirmed|0                           |1

--- Comment #3 from Steven Bosscher <steven at gcc dot gnu.org> ---
Nice idea. Not likely to be implemented any time soon, because it's quite
complicated to get right.

Takes more than just placing a directive right. With the right set of flags the
compiler would still emit 32bit instructions. Actually disabling 32bits
instructions is a lot more work: add a TARGET_16BITS or an attribute_enabled to
almost all patterns in i386.md and friends. Not helpful for the vast majority
of users, and kernel people will complain more about the inevitable slowdown
(and, as usual, point out the general incompetence of gcc hackers :-)

(Why/when is 16bit code still necessary anyway? Before entering protected
mode?)


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
                   ` (2 preceding siblings ...)
  2014-01-04 23:29 ` steven at gcc dot gnu.org
@ 2014-01-04 23:32 ` hpa at zytor dot com
  2014-01-22 22:31 ` hpa at zytor dot com
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hpa at zytor dot com @ 2014-01-04 23:32 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

--- Comment #4 from H. Peter Anvin <hpa at zytor dot com> ---
You are missing the plain fact that *it is already working*.

.code16gcc is a binutils directive which takes 32-bit code emitted by gcc and
assembles it to produce valid (although suboptimal) 16-bit code.  So it really
*is* just a matter of putting the directive in the right place.

And yes, it is used before entering protected mode.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
                   ` (3 preceding siblings ...)
  2014-01-04 23:32 ` hpa at zytor dot com
@ 2014-01-22 22:31 ` hpa at zytor dot com
  2014-01-23 12:52 ` hjl.tools at gmail dot com
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: hpa at zytor dot com @ 2014-01-22 22:31 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

--- Comment #6 from H. Peter Anvin <hpa at zytor dot com> ---
This could also be implemented in binutils as a --code16gcc option, in which
case gcc users would have to use "-m32 -Wa,--code16gcc".  Ugly but would work.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
                   ` (4 preceding siblings ...)
  2014-01-22 22:31 ` hpa at zytor dot com
@ 2014-01-23 12:52 ` hjl.tools at gmail dot com
  2014-01-29  0:16 ` dwmw2 at infradead dot org
  2015-09-29 20:22 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2014-01-23 12:52 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

--- Comment #7 from H.J. Lu <hjl.tools at gmail dot com> ---
I put the initial -m16 support on hjl/x86/m16 branch at:

http://gcc.gnu.org/git/?p=gcc.git;a=summary

We need to add some run-time testcases and fix any bugs.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
                   ` (5 preceding siblings ...)
  2014-01-23 12:52 ` hjl.tools at gmail dot com
@ 2014-01-29  0:16 ` dwmw2 at infradead dot org
  2015-09-29 20:22 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: dwmw2 at infradead dot org @ 2014-01-29  0:16 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

--- Comment #9 from David Woodhouse <dwmw2 at infradead dot org> ---
Thanks. This appears to work for me to build the Linux kernel's 16-bit boot
code with the patch at
http://lkml.kernel.org/r/1389180083-23249-3-git-send-email-David.Woodhouse@intel.com


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug target/59672] Add -m16 support for x86
  2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
                   ` (6 preceding siblings ...)
  2014-01-29  0:16 ` dwmw2 at infradead dot org
@ 2015-09-29 20:22 ` hjl.tools at gmail dot com
  7 siblings, 0 replies; 9+ messages in thread
From: hjl.tools at gmail dot com @ 2015-09-29 20:22 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59672

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|---                         |4.9.0

--- Comment #11 from H.J. Lu <hjl.tools at gmail dot com> ---
Fixed for 4.9.0.


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-09-29 20:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-03 23:00 [Bug target/59672] New: Add -m16 support for x86 hpa at zytor dot com
2014-01-03 23:03 ` [Bug target/59672] " pinskia at gcc dot gnu.org
2014-01-03 23:09 ` hpa at zytor dot com
2014-01-04 23:29 ` steven at gcc dot gnu.org
2014-01-04 23:32 ` hpa at zytor dot com
2014-01-22 22:31 ` hpa at zytor dot com
2014-01-23 12:52 ` hjl.tools at gmail dot com
2014-01-29  0:16 ` dwmw2 at infradead dot org
2015-09-29 20:22 ` hjl.tools at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).