{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6670","repository_url":"https://api.github.com/repos/ARMmbed/mbed-os","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6670/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6670/comments","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6670/events","html_url":"https://github.com/ARMmbed/mbed-os/issues/6670","id":315536925,"number":6670,"title":"Macro definitions in mbed_app.json are not passed to IAR assembler","user":{"login":"TeroJaasko","id":12545862,"avatar_url":"https://avatars0.githubusercontent.com/u/12545862?v=4","gravatar_id":"","url":"https://api.github.com/users/TeroJaasko","html_url":"https://github.com/TeroJaasko","followers_url":"https://api.github.com/users/TeroJaasko/followers","following_url":"https://api.github.com/users/TeroJaasko/following{/other_user}","gists_url":"https://api.github.com/users/TeroJaasko/gists{/gist_id}","starred_url":"https://api.github.com/users/TeroJaasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TeroJaasko/subscriptions","organizations_url":"https://api.github.com/users/TeroJaasko/orgs","repos_url":"https://api.github.com/users/TeroJaasko/repos","events_url":"https://api.github.com/users/TeroJaasko/events{/privacy}","received_events_url":"https://api.github.com/users/TeroJaasko/received_events","type":"User","site_admin":false},"labels":[{"id":515347831,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/component:%20tools","name":"component: tools","color":"5319e7","default":false},{"id":28847979,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/type:%20bug","name":"type: bug","color":"b60205","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-18T15:44:23Z","updated_at":"2018-05-09T14:04:34Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Description\r\n- Type: Bug \r\n- Priority: Minor\r\n\r\n---------------------------------------------------------------\r\n## Bug\r\n\r\n**Target**\r\nK64F\r\n\r\n**Toolchain:**\r\nIAR\r\n\r\n**Toolchain version:**\r\n8.2\r\n\r\n**mbed-cli version:** \r\n1.5.0\r\n\r\n**mbed-os sha:**\r\ncba28cc (HEAD -> master, origin/master, origin/HEAD) Merge pull request #6221 from codeauroraforum/Add_RNG_LPC54XXX\r\n\r\n**Expected behavior**\r\nCode compiles, macros given in mbed_app.json are passed to assembler.\r\n\r\n**Actual behavior**\r\n```\r\nBuilding project mbed-os-example-blinky (K64F, IAR)\r\nScan: .\r\nScan: mbed\r\nScan: env\r\nScan: FEATURE_LWIP\r\nScan: FEATURE_COMMON_PAL\r\nScan: FEATURE_STORAGE\r\nLink: mbed-os-example-blinky\r\nError[Li005]: no definition for \"mbed_fault_context\" [referenced from\r\n          mbed-os-example-blinky/BUILD/K64F/IAR/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.o]\r\nError[Li005]: no definition for \"mbed_fault_handler\" [referenced from\r\n          mbed-os-example-blinky/BUILD/K64F/IAR/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.o]\r\n[ERROR] Error[Li005]: no definition for \"mbed_fault_context\" [referenced from\r\n          mbed-os-example-blinky/BUILD/K64F/IAR/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.o]\r\nError[Li005]: no definition for \"mbed_fault_handler\" [referenced from\r\n          mbed-os-example-blinky/BUILD/K64F/IAR/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.o]\r\n\r\n[mbed] ERROR: \"/usr/bin/python\" returned error code 1.\r\n[mbed] ERROR: Command \"/usr/bin/python -u mbed-os-example-blinky/mbed-os/tools/make.py -t IAR -m K64F --source . --build ./BUILD/K64F/IAR\" in \"mbed-os-example-blinky\"\r\n```\r\n\r\n**Steps to reproduce**\r\n* clone mbed-os-example-blinky\r\n* compile successfully for ARM: \"mbed compile -m K64F -t ARM\"\r\n* edit mbed_app.json to have macro MBED_FAULT_HANDLER_DISABLED as defined, eg\r\n```\r\n    \"macros\": [\r\n        \"MBED_FAULT_HANDLER_DISABLED\"\r\n    ],\r\n```\r\n* compile successfully for ARM: \"mbed compile -m K64F -t ARM\"\r\n* observe binary size reduction of ~1780 bytes.\r\n* compile for IAR: \"mbed compile -m K64F -t IAR\"\r\n* observe the linker error, caused likely by \"#ifndef MBED_FAULT_HANDLER_DISABLED\" -line failing to work as expected in except.S (https://github.com/ARMmbed/mbed-os/blob/master/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S#L32)\r\n\r\n----------------------------------------------------------------\r\n## Enhancement\r\n\r\n**Reason to enhance or problem with existing solution**\r\nIt seems that the macros in mbed_app.json are not passed to the IAR's assembler, or at least command lines for compiling except.S in ARM and IAR are quite different and IAR is missing reference to mbed_config.h:\r\n\r\nARM:\r\n```\r\narmcc -c --gnu -Otime --split_sections --apcs=interwork --brief_diagnostics --restrict --multibyte_chars -O3 --cpu=Cortex-M4.fp -D__CORTEX_M4 -DCPU_MK64FN1M0VMD12 -DARM_MATH_CM4 -D__FPU_PRESENT=1 -D__MBED_CMSIS_RTOS_CM -D__CMSIS_RTOS -DFSL_RTOS_MBED --via ./BUILD/K64F/ARM/.includes_24c7dc53f90030b3047073a06c584023.txt --preinclude=./BUILD/K64F/ARM/mbed_config.h -E -o BUILD/K64F/ARM/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/.temp/except.o.E.s ./mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S\r\n```\r\n\r\nIAR:\r\n```\r\niasmarm --cpu Cortex-M4F -D__CORTEX_M4 -DCPU_MK64FN1M0VMD12 -DARM_MATH_CM4 -D__FPU_PRESENT=1 -D__MBED_CMSIS_RTOS_CM -D__CMSIS_RTOS -DFSL_RTOS_MBED -o BUILD/K64F/IAR/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.o ./mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_IAR/except.S\r\n```\r\n\r\n**Suggested enhancement**\r\nPass the content of mbed_config.h to iasmarm somehow.\r\n\r\n**Pros**\r\n\r\n**Cons**\r\n\r\n-----------------------------------------------------------------\r\n\r\n## Question\r\n\r\n**How to?**\r\n"},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/comments/387749766","html_url":"https://github.com/ARMmbed/mbed-os/issues/6670#issuecomment-387749766","issue_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/6670","id":387749766,"user":{"login":"TeroJaasko","id":12545862,"avatar_url":"https://avatars0.githubusercontent.com/u/12545862?v=4","gravatar_id":"","url":"https://api.github.com/users/TeroJaasko","html_url":"https://github.com/TeroJaasko","followers_url":"https://api.github.com/users/TeroJaasko/followers","following_url":"https://api.github.com/users/TeroJaasko/following{/other_user}","gists_url":"https://api.github.com/users/TeroJaasko/gists{/gist_id}","starred_url":"https://api.github.com/users/TeroJaasko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TeroJaasko/subscriptions","organizations_url":"https://api.github.com/users/TeroJaasko/orgs","repos_url":"https://api.github.com/users/TeroJaasko/repos","events_url":"https://api.github.com/users/TeroJaasko/events{/privacy}","received_events_url":"https://api.github.com/users/TeroJaasko/received_events","type":"User","site_admin":false},"created_at":"2018-05-09T14:04:34Z","updated_at":"2018-05-09T14:04:34Z","author_association":"CONTRIBUTOR","body":"@theotherjimmy this seems to be now broken in Mbed OS master with ARMCC also. \r\n\r\nmbed OS cba28cc0ac2, the mbed_config.h  is given to armcc:\r\n```\r\narmcc -c --gnu -Ospace --split_sections --apcs=interwork --brief_diagnostics --restrict --multibyte_chars -O3 -DNDEBUG --cpu=Cortex-M4.fp -D__CORTEX_M4 -DCPU_MK64FN1M0VMD12 -DARM_MATH_CM4 -D__FPU_PRESENT=1 -D__MBED_CMSIS_RTOS_CM -D__CMSIS_RTOS -DFSL_RTOS_MBED --via ./BUILD/K64F/ARM/.includes_24c7dc53f90030b3047073a06c584023.txt --preinclude=./BUILD/K64F/ARM/mbed_config.h -E -o BUILD/K64F/ARM/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/.temp/except.o.E.s ./mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S\r\n```\r\n\r\nMbed OS 68ad00ffb8, no mbed_config.h given anymore:\r\n```\r\narmcc -c --gnu -Ospace --split_sections --apcs=interwork --brief_diagnostics --restrict --multibyte_chars -O3 -DNDEBUG --cpu=Cortex-M4.fp -D__CORTEX_M4 -DCPU_MK64FN1M0VMD12 -DARM_MATH_CM4 -D__FPU_PRESENT=1 -D__MBED_CMSIS_RTOS_CM -D__CMSIS_RTOS -DFSL_RTOS_MBED -E -o BUILD/K64F/ARM/mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/.temp/except.o.E.s ./mbed-os/rtos/TARGET_CORTEX/TARGET_CORTEX_M/TOOLCHAIN_ARM/except.S\r\n```"}}
{"actor":{"display_login":"TeroJaasko"}}