Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUILD] Building the toolchain does not build/install libdw_uart.a #262

Closed
shahab-vahedi opened this issue Apr 13, 2020 · 14 comments
Closed
Assignees
Labels
bug component: newlib release notes Items to mention in release notes
Milestone

Comments

@shahab-vahedi
Copy link
Member

shahab-vahedi commented Apr 13, 2020

versions

binutils:  arc-2019.09
gcc:       arc-2019.09
newlib:    arc-2019.09
toolchain: arc-releases    , 7fdabaf      (Merge branch 'arc-staging'...)

build command

$build-all.sh --source-dir    /data/work/repos/arcgnu/${SRCDIR}    \
              --build-dir     /data/work/build/arcgnu/${BLDDIR}    \
              --install-dir   /data/work/install/arcgnu/${INSTDIR} \
              --release-name  "${RLSNAME}"                         \
              --cpu           em4_dmips                            \
              --no-multilib                                        \
              --elf32                                              \
              --no-uclibc                                          \
              --target-cflags "-Og -g3 -fvar-tracking-assignments" \
              --jobs          8                                    \
              --no-pdf                                             \
              --no-auto-checkout                                   \
              --no-auto-pull                                       \
              --no-external-download                               \
              --no-strip                                           \
              --no-elf32-strip-target-libs                         \
              --no-native                                          \
              --no-optsize-newlib                                  \
              --no-optsize-libstdc++

problem

Building a hello world program with a command like below fails:

/data/work/install/arcgnu/ul_1909/bin/arc-elf32-gcc -mcpu=em4_dmips --specs=emsk_em9d.specs test.c -o test.exe
/data/work/install/arcgnu/ul_1909/lib/gcc/arc-elf32/9.2.1/../../../../arc-elf32/bin/ld: cannot find -ldw_uart
collect2: error: ld returned 1 exit status

investigation

Building the toolchain with the above commands, although creates this directory

/bld/dir/bd-elf32/newlib/arc-elf32/libgloss/arc/dw_uart
.
├── Makefile
├── config.log
└── config.status

It never compiles the dw_uart. Executing make command in that directory does build some .o files, but not libdw_uart.a in parent directory of course.

expected behavior

libdw_uart.a is built and installed.

Please let me know if you need more info.

@shahab-vahedi shahab-vahedi assigned abrodkin and claziss and unassigned abrodkin Apr 13, 2020
@shahab-vahedi
Copy link
Member Author

shahab-vahedi commented Apr 13, 2020

If I remove --no-multilib from the build command, then the libdw_uart.a are built:

in /bld/dir/bd-elf32/newlib
find -name 'libdw_uart.a'
     ./arc-elf32/quarkse_em/libgloss/arc/libdw_uart.a
     ./arc-elf32/em4_fpus/libgloss/arc/libdw_uart.a
     ./arc-elf32/em/libgloss/arc/libdw_uart.a
     ./arc-elf32/em4/libgloss/arc/libdw_uart.a
     ./arc-elf32/em_mini/libgloss/arc/libdw_uart.a
     ./arc-elf32/em4_dmips/libgloss/arc/libdw_uart.a
     ./arc-elf32/arcem/libgloss/arc/libdw_uart.a
     ./arc-elf32/em4_fpuda/libgloss/arc/libdw_uart.a

But still the libdw_uart.a files are not installed in the INSTALL/lib directory. Execution of a manual make install inside the newlib's build directory is not helpful either.

@shahab-vahedi shahab-vahedi changed the title [BUILD] Building the toolchain does not build libdw_uart.a [BUILD] Building the toolchain does not build/install libdw_uart.a Apr 14, 2020
@abrodkin abrodkin assigned abrodkin and unassigned claziss Apr 14, 2020
@abrodkin abrodkin added this to the 2020.03 milestone Apr 14, 2020
@abrodkin
Copy link
Member

abrodkin commented May 6, 2020

The problem here is due to the fact that we try to determine a CPU type looking at MULTISUBDIR variable (CPU_FAMILY = $(findstring em,${MULTISUBDIR}), see https://github.com/foss-for-synopsys-dwc-arc-processors/newlib/blob/arc-2018.09/libgloss/arc/Makefile.in#L95) which in its turn gets populated from subdir of multilibbed folder structure. Obviously if we configure with no multilib this MULTISUBDIR is empty thus in the following code we inevitably skip the first branch, see https://github.com/foss-for-synopsys-dwc-arc-processors/newlib/blob/arc-2018.09/libgloss/arc/Makefile.in#L96:

CPU_FAMILY = $(findstring em,${MULTISUBDIR})
ifeq ($(CPU_FAMILY), em)
ALL = $(CRT0) $(NSIM_BSP) $(UART_LIB) $(QEMU_BSP)
else
ALL = $(CRT0) $(NSIM_BSP) $(QEMU_BSP)
endif

The first solution that comes to my mind is to get rid of this CPU family nonsense as how common sense suggests UART driver should have nothing to do with a CPU family, isn't it?

So let's try this:

diff --git a/libgloss/arc/Makefile.in b/libgloss/arc/Makefile.in
index 46a4a35..9439065 100644
--- a/libgloss/arc/Makefile.in
+++ b/libgloss/arc/Makefile.in
@@ -92,12 +92,7 @@ UART_DIR = uart-dir
 CFLAGS = -g
 override CFLAGS += $(UART_CFLAGS)

-CPU_FAMILY = $(findstring em,${MULTISUBDIR})
-ifeq ($(CPU_FAMILY), em)
 ALL = $(CRT0) $(NSIM_BSP) $(UART_LIB) $(QEMU_BSP)
-else
-ALL = $(CRT0) $(NSIM_BSP) $(QEMU_BSP)
-endif
 ALL_INSTALL = $(CRT0_INSTALL) $(NSIM_INSTALL) $(NANO_INSTALL) $(UART_INSTALL) $(MEMORY_MAP_INSTALL) $(QEMU_INSTALL)

 # These are roughly topologically sorted in order to make porting more
@@ -199,9 +194,8 @@ $(NANO_INSTALL):
                $(INSTALL_DATA) $(srcdir)/$$x $(DESTDIR)$(tooldir)/lib$(MULTISUBDIR)/$$x; done

 $(UART_INSTALL):
-       if [ "$(CPU_FAMILY)" == "em" ]; then \
-               $(mkinstalldirs) $(DESTDIR)${tooldir}/lib${MULTISUBDIR} ; \
-               $(INSTALL_DATA) $(UART_LIB) $(DESTDIR)$(tooldir)/lib$(MULTISUBDIR)/$(UART_LIB) ; fi
+       $(mkinstalldirs) $(DESTDIR)${tooldir}/lib${MULTISUBDIR}
+       $(INSTALL_DATA) $(UART_LIB) $(DESTDIR)$(tooldir)/lib$(MULTISUBDIR)/$(UART_LIB)
        for x in $(EMSK_SCRIPTS); do \
                $(INSTALL_DATA) $(srcdir)/$$x $(DESTDIR)$(tooldir)/lib$(MULTISUBDIR)/$$x; done

But apparently we do way more than required for the plain simple UART driver as we fail while building for ARC700:

arc_exc_asm.S: Assembler messages:
arc_exc_asm.S:111: Error: opcode 'clri' not supported for target arc700
.../newlib/libgloss/arc/dw_uart/arc/arc_exc_asm.S:146: Error: opcode 'seti' not supported for target arc700
.../newlib/libgloss/arc/dw_uart/arc/arc_exc_asm.S:153: Error: opcode 'clri' not supported for target arc700
.../newlib/libgloss/arc/dw_uart/arc/arc_exc_asm.S:168: Error: opcode 'clri' not supported for target arc700
make[4]: *** [arc_exc_asm.o] Error 1
make[4]: *** Waiting for unfinished jobs....
arc-elf32-ar rv libqemu.a qemu-write.o qemu-stub.o sbrk.o
.../newlib/libgloss/arc/dw_uart/arc/arc_exception.c: Assembler messages:
.../newlib/libgloss/arc/dw_uart/arc/arc_exception.c:95: Error: opcode 'kflag' not supported for target arc700
.../newlib/libgloss/arc/dw_uart/arc/arc_exception.c:79: Error: opcode 'kflag' not supported for target arc700
.../newlib/libgloss/arc/../../libgloss/arc/dw_uart/inc/arc/arc_exception.h:108: Error: opcode 'seti' not supported for target arc700

So what can we do here:

  1. Fix "UART driver" for ARC600 & ARC700 with ifdeffed implementation of the failing code.
    Sounds like a low-hanging fruit but makes not much sense as we don't have any use for that.
  2. Try to improve detection of the CPU version we build for.
    Looks like a saner solution but such games in newlib/libgloss make them even more complex.

@abrodkin
Copy link
Member

abrodkin commented May 6, 2020

BTW I'm wondering if that UART driver with support of interrupts & exceptions is upstreamable at all, so maybe drop it and forget about that for good since we have QEMU stubs now?

@claziss @shahab-vahedi what's your take on this?

@shahab-vahedi
Copy link
Member Author

@abrodkin The proposed patch does generate libdw_uart.a and also put it in the installed directory.

@claziss
Copy link
Contributor

claziss commented May 11, 2020

Newlib is partially upstream, there is no answer from those guys to our hails, don't know why. Regarding, libgloss' UART, we can do whatever we want as this library supposedly adds I/O support for various platforms.

@abrodkin
Copy link
Member

@Palmyr3 suggests to have very limited UART support in libgloss. In particular only output in polling mode. That will give us much simpler driver which is applicable to any ARC ISA and any platform (when both nSIM & QEMU support DW UART). If somebody needs full serial port with IRQs it makes sense to leave it to him/her to implement it.

@claziss
Copy link
Contributor

claziss commented May 11, 2020

That's fine, indeed we don't need to break our backs to get a simple I/O done ;)

@abrodkin
Copy link
Member

As discussed on OS core-team this one will be documented as a known issue for arc-2020.03 release and later we'll implement a proper fix in form of polling-mode output only driver.

@abrodkin abrodkin added bug component: newlib release notes Items to mention in release notes labels May 12, 2020
@abrodkin abrodkin assigned shahab-vahedi and unassigned abrodkin May 13, 2020
@abrodkin abrodkin modified the milestones: 2020.03, 2020.09 May 13, 2020
@abrodkin abrodkin modified the milestones: 2020.03, 2020.09 Jun 25, 2020
@abrodkin
Copy link
Member

Once we implement "MetaWare Hostlink" (see #296) that issue will become irrelevant as we'll be able to use it for any types of targets be it an nSIM, xCAM or even FPGA or real ASIC.

@claziss claziss modified the milestones: 2020.09, 2021.03 Jan 26, 2021
@VVIsaev
Copy link
Contributor

VVIsaev commented Feb 9, 2021

Please find PR with remove dwuart support here: foss-for-synopsys-dwc-arc-processors/newlib#16

@abrodkin
Copy link
Member

@claziss, @shahab-vahedi are we moving this to the next release arc-2021.09 or consider foss-for-synopsys-dwc-arc-processors/newlib#16 for last minute inclusion?

@VVIsaev
Copy link
Contributor

VVIsaev commented Jul 22, 2021

DW UART is removed from newlib (switched to UART 8250 which is written in C). So close.

@VVIsaev VVIsaev closed this as completed Jul 22, 2021
@VVIsaev
Copy link
Contributor

VVIsaev commented Oct 11, 2021

foss-for-synopsys-dwc-arc-processors/newlib#23 not merged yet, so reopen

@VVIsaev VVIsaev reopened this Oct 11, 2021
@abrodkin abrodkin modified the milestones: 2021.09, 2022.03 Oct 11, 2021
@VVIsaev
Copy link
Contributor

VVIsaev commented Feb 17, 2022

DW UART is removed from newlib (switched to UART 8250 which is written in C). So close.

Commit: foss-for-synopsys-dwc-arc-processors/newlib@699d24b

@VVIsaev VVIsaev closed this as completed Feb 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug component: newlib release notes Items to mention in release notes
Projects
None yet
Development

No branches or pull requests

4 participants